I have a problem that I cannot solve. I implemented the ws-w630> js Websockets server on an opening cartridge using socket.io or WebSockets node js libraries. With any of them, the result is the same.
With the node js client running on the same platform with the opening platform, everything works fine.
When the client roams on my local computer, the client connects and disconnects suddenly, giving 1011 internal server errors.
I tried using other well-known clients, such as the echo service on WebSockets.Org or jsfiddle , but the result is the same, connect and disconnect unexpectedly.
I do not know why. Has anyone been able to connect to a remote WebSockets server from a remote server? The server is minimal and simple, and locally it works fine.
This is the code I'm using as a server:
var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
var port = 8000;
var app = require("express");
var server = require("http").Server(app);
var io = require("socket.io")(server);
var handleClient = function (socket) {
socket.sendUTF("hello");
console.log("connect");
};
io.on("connection", handleClient);
server.listen(port, ipaddress);
And this is the socket endpoint: WS: //js-camillorh.rhcloud.com: 8000
Thank!
Updated code after comment:
var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
var app = require("express");
var server = require("http").Server(app);
var io = require("socket.io")(server);
var handleClient = function (socket) {
socket.sendUTF("hello");
console.log("connect");
};
io.on("connection", handleClient);
console.log("listen: "+ipaddress+" "+port);
server.listen(port, ipaddress);
Log file:
DEBUG: Sending SIGTERM to child...
DEBUG: Running node-supervisor with
DEBUG: program 'server.js'
DEBUG:
DEBUG:
DEBUG:
DEBUG:
DEBUG: Starting child process with 'node server.js'
DEBUG: Watching directory '/var/lib/openshift/5551a336e0b8cd4ea50000db/app-root/data/.nodewatch' for changes.
listen: 127.13.35.129 8080