Closed kvnxiao closed 7 years ago
Note: I haven't tested this
Try using r.Mount("/echo", sockjs.NewHandler("/", ...))
, I would however suggest using https://github.com/olahol/melody with normal WS connection on client side, instead of sockjs.
@zet4 Thanks! using Mount() worked with the echo example.
Regarding your suggestion to use normal WS connection, is there a big reason people prefer a normal WS connection over polyfills like socket.io and sockjs?
And how does melody compare with gorilla websockets?
thanks for answering the question @zet4 - I'm going to close this since question is answered
@alphahelix00 the issue is closed but I guess I will still answer your question, socket.io/sockjs add additional overhead/costs on top of normal WS (if its even using WS, it might fallback to Polling without you knowing)
Melody is still using gorilla websockets underneath, its just a nicer wrapper with session handling added. I use it for one of my person projects alongside Chi.
@zet4 thanks for the update, do you have any example code for getting getting this working with melody?
Hey there,
I was wondering how I could use sockjs-go with Chi. I'm writing a real-time web game application for one of my projects so I was thinking of using sockjs as a websocket implementation.
Of course, running the example code for sockjs-go using net/http is no problem, but when I try to set the sockjs-go handler for a chi router, I end up with a 304 followed by a 404 for sockjs info. I'm kind of new to this so I am not sure if I am doing something wrong, but what I am doing is as follows:
I am simply trying to run an echo example to send message from client to server and back, but I cannot seem to get the client to connect to the server through websocket.