[I've flagged this question to be deleted by moderator until I get answer to my this question]
My javascript client is working fine when talking to node.js(on Ubuntu, more here) server through WebSocket interface with IPV4 IP address.
Even though my Hosting provider is ready to allocate me IPV4, let me instead use IPV6 since there is limited supply of IPV4 now.
When using the IPV6 IP I'm getting this error:
WebSocket connection to 'ws://[2600:3c00::f03c:91ff:fe73:2b08]:31333/' failed: Error in connection establishment: net::ERR_ADDRESS_UNREACHABLE
I've checked that port 31333 is indeed open using tool: http://www.subnetonline.com/pages/ipv6-network-tools/online-ipv6-port-scanner.php
I've even tried solution as in IPv6 address giveing syntax error in internet explorer-10 websocket -- that is : 2600-3c00-0-0-f03c-91ff-fe73-2b08.ipv6-literal.net
I've run this client and is able to connect to the server when both are running on remote Ubuntu based server:
var WebSocket = require('ws')
, ws = new WebSocket('ws://[2600:3c00::f03c:91ff:fe73:2b08]:31333');
ws.on('open', function() {
ws.send('something');
});
ws.on('message', function(message) {
console.log('received: %s', message);
});
However when I run this same client from my home Windows 7 while the server is remote Ubuntu one, it is not able to connect:
> $ node c2.js events.js:85
> throw er; // Unhandled 'error' event
> ^ Error: connect ENETUNREACH
> at exports._errnoException (util.js:746:11)
> at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
I've even run this code in Google Chrome :
var ws = new WebSocket("ws://[2600:3c00::f03c:91ff:fe73:2b08]:31333");
ws.onerror = function(err)
{
console.log(err);
alert("Connection is error...");
};
But I get the same error:
WebSocket connection to 'ws://[2600:3c00::f03c:91ff:fe73:2b08]:31333/' failed: Error in connection establishment: net::ERR_ADDRESS_UNREACHABLE websocket.html:37 Event
What could be the issue?
PS: at the moment I've stopped the server at port 31333.
Pings and Pongs: The Heartbeat of WebSockets At any point after the handshake, either the client or the server can choose to send a ping to the other party.
To open a websocket connection, we need to create new WebSocket using the special protocol ws in the url: let socket = new WebSocket("ws://javascript.info"); There's also encrypted wss:// protocol. It's like HTTPS for websockets.
In order to communicate using the WebSocket protocol, you need to create a WebSocket object; this will automatically attempt to open the connection to the server. The URL to which to connect; this should be the URL to which the WebSocket server will respond.
Messages sent by the server to the client can include plain text messages, binary data, or images. Whenever data is sent, the onmessage function is fired. This event acts as a client's ear to the server. Whenever the server sends data, the onmessage event gets fired.
IPv6 is not enabled on your Realtek PCIe GBE Family Controller. If it was, there would be a line saying "Link-local IPv6 Address" in the ipconfig result.
Go to control panel > Network > Change Adapter Settings > Right click on the adapter > Properties. Check IPv6 on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With