Bad Request with payload paused
go version: 1.19 go-socket.oi version: 1.6.2 socket-io js client version: 1.7.4
request header

request payload

response

Before submit this issue, i had quick read go-socket.io source code, and found out the errPaused, it shoud be retryError, and ignored to response,

I'm not very sure what i had done lead to this situation
And follow my server side code:
// gin request entry
func StartSocketIO(ctx *gin.Context) {
GetServ().ServeHTTP(ctx.Writer, ctx.Request)
}
// init socket server
func initSocketIOServer() *socketio.Server {
s := socketio.NewServer(&engineio.Options{
Transports: []transport.Transport{
&polling.Transport{
CheckOrigin: allowOrigin,
},
&websocket.Transport{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: allowOrigin,
},
},
})
s.OnConnect(NspRoot, func(c socketio.Conn) error {
logger.GetLogger().Info("connected root:", c.ID())
return nil
})
s.OnConnect(NspVulBox, func(c socketio.Conn) error {
logger.GetLogger().Info("connected socket.io/vulbox:", c.ID())
clientsCount++
c.SetContext(NewContext())
c.Join(RoomUnsigned)
return nil
})
s.OnError(NspVulBox, func(c socketio.Conn, e error) {
logger.GetLogger().Error("error: ", e)
})
s.OnDisconnect(NspVulBox, func(c socketio.Conn, reason string) {
logger.GetLogger().Info("closed: ", reason)
if user, ok := c.Context().(*SettableContext).Get(UserInContext); ok {
removeUserClient(*user.(*middleware.VulBoxClaims), c)
}
})
return s
}
client code:
$(function() {
var socket = io("https://localhost:8080/", {path: "/socket.io/"});
// Socket events
socket.on('connect', function (data) {
socket.emit('Authorization', "Bearer with authorize code");
socket.emit('Message', {"msg": "hello connection"})
})
socket.on('logged', function (data) {
console.log(data)
socket.emit('Message', {"msg": 'hello'})
})
socket.on('Message', function (data) {
console.log(data)
})
socket.on('disconnect', function () {
console.log('you have been disconnected');
});
socket.on('reconnect', function () {
console.log('you have been reconnected');
});
socket.on('reconnect_error', function () {
console.log('attempt to reconnect has failed');
});
});
Any advice is welcome, thanks all again.
addtion: this conditions is ok with my local host once build in our test server, it almost happen every time.
sorry for this issue, there is a null point usage in my code, and it have not log anything before it, it has been recovered sliencely. close it, sorry again for interrupt
Hi ! We run into the same issue on our side, could you just be more precise about how you found the issue and where was it in your code ? Thanks a lot !
Hi @RomaricMourgues, my code has not resolved this issue, the biggest problem is there is a nil point I had used in my code, I had just repaired this nil point usage. My superior is okay with there has some bad requests at the beginning of the connection. I'm sorry for there is no more help in my place...
I want to read the source code that relates to this problem, but however, I'm newer to golang. And I do not understand this sockerio library very much. As I mentioned at first, I can only check that there should not return a bad request when the client receives a RetryError, there is my only opinion, maybe there is some other reason.
If there is some solution to this, hit me some notice, thank you very much.
socket.io documentation says that HTTP long-polling transport is used by default in the WebSocket upgrade mechanism. When the client send message on connect event it is possible that the WebSocket upgrade and the sending of the message happen at the same time.
engineio/session/session.go:311
It Pause HTTP Handler when upgrading.
engineio/payload/payload.go:66
It return errPaused when p is paused. I thank that is why the problem happens.