Saturday 11 November 2017

Port Help? Newbie Programmer

Hey newbie JavaScript programmer here! Anyways, I was following along with Daniel Shiffman's websockets, p5.js tutorial, when I came across a problem where my canvas wouldn't show and where I wouldn't be able to send data to my server. There was also the following error that came from the front side:Uncaught ReferenceError: process is not definedWhich came from:socket = io.connect(process.env.PORT || 3000);Also I posted this mini project to heroku in case you guys want a better look: http://ift.tt/2i3uD7J (inspect element, go into sources, then open up sketch.js to see the error)Here's the server.js code:var express = require('express'); var app = express(); var server = app.listen(process.env.PORT || 3000); app.use(express.static('public')); console.log('Server running'); var socket = require('socket.io'); var io = socket(server); io.sockets.on('connection', newConnection); function newConnection(socket){ socket.on('mouse', mouseMsg); function mouseMsg(data){ socket.broadcast.emit('mouse', data); } } Any ideas on what I should do to make this thing work on heroku? (This app worked perfectly fine on localhost when I didn't have the 'process.env.PORT' there and just had my ip followed by the 3000 port.)

Submitted November 11, 2017 at 11:37AM by Eriod

No comments:

Post a Comment