itisnajim / SocketIOUnity

A Wrapper for socket.io-client-csharp to work with Unity.
MIT License
393 stars 67 forks source link

Nodejs Server is not working in heroku #25

Closed mohandeep2002 closed 2 years ago

mohandeep2002 commented 2 years ago

I deployed my nodejs server in Heroku. It is connecting with the unity but it is not sending and receiving any data from the server.

In Unity I used like this for connecting to my server.

` var uri = new Uri("ws://herokuapp name<>.herokuapp.com");

    //Creating a socket
    socket = new SocketIOUnity(uri, new SocketIOOptions
    {
        Query = new Dictionary<string, string>
            {
                {"token", "UNITY" }
            }
        ,
        EIO = 4
        ,
        Transport = SocketIOClient.Transport.TransportProtocol.WebSocket
    });

`

meytotr commented 2 years ago

same for glitch.. but i couldnt tell them

yeexuanwong commented 2 years ago

Try to change your this portion of code in nodejs from:

server.listen(port, () => { console.log('listening on *:' + port); });

to

server.listen(process.env.PORT || port, () => { console.log('listening on *:' + port); });

itisnajim commented 2 years ago

duplicated: https://github.com/itisnajim/SocketIOUnity/issues/22