Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
29
rated 0 times [  35] [ 6]  / answers: 1 / hits: 23020  / 9 Years ago, fri, january 15, 2016, 12:00:00

I'm getting a SyntaxError: An invalid or illegal string was specified, while trying to connect to a WebSocket on Firefox.



<!doctype html>
<html>
<head><meta charset=utf-8></head>
<body>
<script>
var socket = new WebSocket('127.0.0.1:1234');
</script>
</body>
</html>


Why do I get this error?


More From » firefox

 Answers
3

It seems like the scheme is mandatory when trying to connect to a WebSocket, so this:


var socket = new WebSocket('ws://127.0.0.1:1234');

works just fine (or as @RaulNoheaGoodness pointed out in the comments, wss:// when using WebSocket over TLS).


[#63725] Tuesday, January 12, 2016, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josh

Total Points: 391
Total Questions: 112
Total Answers: 90

Location: Aruba
Member since Fri, Jun 24, 2022
2 Years ago
josh questions
Wed, Aug 4, 21, 00:00, 3 Years ago
Mon, Aug 24, 20, 00:00, 4 Years ago
Wed, Aug 12, 20, 00:00, 4 Years ago
;