SockJS not working on IE9 (Websockets)

2019-06-27 06:33发布

问题:

I am trying to setup an app working with SockJS over STOMP. However, it seems that the connection is not established. I do not have these issues with running all on Chrome, FF and so on.

Is there a way to support this for IE9? Or is it impossible to run websockets with sockjs on IE9? I saw some discussions where people were solving some issues with IE9 and sockjs but none providing a solution to my issue.

BR

回答1:

The issue is resolved. SockJS emulates websockets on IE9 with no issue. The only thing that I had to do was to provide absolute path for creating the SockJS object.

Before:

var webSocket = new SockJS('topic/publish');

After:

var webSocket = new SockJS('http://localhost:8080/topic/publish');

Although it was working with Chrome and Firefox, there were issues to run it on IE9 that doesn't support websockets (out of the box).



回答2:

Internet Explorer 9 does not support websockets http://caniuse.com/websockets.

You can use a polyfill based on Flash like https://github.com/gimite/web-socket-js