B4J Question Websocket server IE vs Chrome

Philip Prins

Active Member
Licensed User
I have a websocket server running , when using chrome on port 80 there is no problem but when i use Internet explorer 11 or Edge i get an error developed by the b4j ws script in regard to the WS Full path.
b4j_ws = new WebSocket(fullpath); Syntax Error

When i add a port number different then 80 Internet Explorer works fine.

How can i solve this?
 

Daestrum

Well-Known Member
Licensed User
Are you running the server and client on the same machine, as reading through various posts, Edge does not allow web socket connections to the local machine.
127.0.0.1 and localhost appear to be no-no's.
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
It's kinda/sorta a bug in IE 11. Firefox and Chrome are just more flexible in interpreting URLs. The problem is IE 11 doesn't like URLs of the form "ws://domain.tdl:/WebSocketHandler". That colon without a specified port number trips it up. I changed this line in b4j_ws.js
B4X:
fullpath = ((l.protocol === "https:") ? "wss://" : "ws://") + l.hostname + ":" + l.port + absolutePath;
to this
B4X:
var portString = (l.port==="") ? l.port : (":" + l.port);
fullpath = ((l.protocol === "https:") ? "wss://" : "ws://") + l.hostname + portString + absolutePath;
and now it works with and without specified port numbers in Chrome, IE 11 and Firefox.
 
Upvote 0
Top