How do I make Socket.io working properly?

  • Hi guys,

    i am new to Construct and have an issue with the socket.io plugin

    viewtopic.php?t=73584&start=0

    I did the tutorial :

    https://www.scirra.com/tutorials/571/mo ... tio/page-1

    But somehow the example project there isn´t working. I Installed node.js on my server, copied the code from the project to a .js file in a directory, installed there socket.io. (everything on ubuntu). Modified the Port in the construct file and the code example from the tutorial to 61000 (see request pictures) and startet the .js file on my server.

    Here are two pictures from the debugger of Firefox.

    I would really appreciate any help. If you have further questions or need more information just post here or text me.

    Thank you very much,

    SirSandmann

  • Why don't you use the multiplayer object instead of socket.io? If you're new it's probably better to use easier methods until you really get the hang of Construct before using Node.js as well.

    The first thing I notice is the 400 error. This is where the data between the client and server don't follow the same 'rules' per se. Are you using the correct versions of everything? Is the tutorial up to date? etc.

  • Hi, i use socket.io because i want to have full mobile support (ios) and i wanted to use my server and also have some programming experience with phaser.js. I think that everything is up to date. But i just recognized, that the response Header is json and the request only accept text/html. But i sill haven´t found an answer to that yet.

  • Are you trying to read JSON as XML or vice versa?

  • The problem is, that i can´t even connect to my server. I changed everything that way, that it should just connect to the server, but even that doesn´t work. Does anyone else have problems with that plugin?

  • Found the Issue: core changed dureing the releases during the tutorial and now

    How to fix: downgrade to version 0.9.5 (version of the plugin) then everything should work properly!

  • But somehow the example project isn´t working though

  • Does not work for me too. Tried also 0.9.5.

  • You are trying to connect using HTTP. You need to use WS like:

    ws://server-ip/socket.io/i

  • gumshoe2029,

    thanks for your answer. The problem wasn't the protocol.

    I was succesfully connecting form a simple html page using

    var socket = io.connect("http://localhost:8080");[/code:avwb1crn]
    The plugin is working with older socket.io npm package. I tried 0.9.0 an it works.
    
    Does anybody knows if is ther an updated socket.io plugin. I can't find one :/
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You cannot connect to an http server using web sockets. You have to connect via the ws or wss protocol.

    This line of code:

    var socket = io.connect("http://localhost:8080");

    Is absurd and will never work. Don't believe me though, I have a working websocket server/client.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)