sockjs / sockjs-client

WebSocket emulation - Javascript client
MIT License
8.45k stars 1.3k forks source link

how do i get the http status code in long polling requests? #619

Open eeeman1 opened 1 year ago

eeeman1 commented 1 year ago

all that comes to me from the server is -

{
 ⁣ ⁣ ⁣ ⁣"type": "close",
 ⁣ ⁣ ⁣ ⁣"bubbles": false,
 ⁣ ⁣ ⁣ ⁣"cancelable": false,
 ⁣ ⁣ ⁣ ⁣"timeStamp": 1676546179923,
 ⁣ ⁣ ⁣ ⁣"wasClean": false,
 ⁣ ⁣ ⁣ ⁣"code": 1002,
 ⁣ ⁣ ⁣ ⁣"reason": "Cannot connect to server"
}
auvipy commented 1 year ago

i think stack overflow is the right place for this type of questions

FZambia commented 1 year ago

SockJS was designed as the polyfill for the WebSocket API. There is no way to get status code returned by a server during Upgrade in WebSocket case. Take a look at this SO answer for some additional details. SockJS hides some specifics of other transports used for WebSocket fallback mimicking WebSocket API. This may be inconvenient in some cases of course.