Monday 5 June 2017

400 bad request error and connection errors in node.js & socket.io

Making a game, I have no idea what I am doing when it comes to the online aspect.

I am using node.js using my computer as the server host and client (localhost:3000)

var express = require('express'); //no idea what I am doing here
var app = express();
var server = app.listen(3000);
var socket = require("socket.io");
var io = socket(server);
io.sockets.on('connection', newConnection);
app.use(express.static("public"));

console.log("server is up"); //tells me that the server is ready

function newConnection(socket) {
    console.log("new player!", socket.id); //tells me when a new player connects.
}

also have this code within the main public javascript file

var socket;
socket = io.connect("localhost:3000");

Whenever a new player (only one connection) connects, the console repeatedly states that a new player has joined more than once, and 400 bad request errors are also repeatedly shown in a ~3 second interval.

picture -- trillions of "new player" and "400 error" messages



via Canatron

No comments:

Post a Comment