roslibjs auto disconnected when calling any function
I'm running melodic on macOS 10.13.6.
I got the latest rosauth and rosbridge_suite from git and have them in my catkin_ws and build ok. I also have my test project which launches the rosbridge server and a simple python web server for the webpage.
Here's the javascript snippet that is used to connect:
$(function() {
var ros = new ROSLIB.Ros({
url : 'ws://127.0.0.1:9090'
});
window.ros = ros;
ros.on('connection', function() {
console.log('Connected to websocket server.');
$('#status span').html('Connected');
});
ros.on('error', function(error) {
console.log('Error connecting to websocket server: ', error);
$('#status span').html('Error');
});
ros.on('close', function() {
console.log('Connection to websocket server closed.');
$('#status span').html('Disconnected');
});
And here's the console output:
Connected to websocket server.
ros.getNodes(function(n){console.log(n)});
undefined
main.js:18 Connection to websocket server closed.
ros.connect('ws://127.0.0.1:9090')
undefined
main.js:8 Connected to websocket server.
ros
d {socket: WebSocket, idCounter: 1, isConnected: true, transportLibrary: "websocket", transportOptions: {…}, …}event: "connection"groovyCompatibility: trueidCounter: 1isConnected: truesocket: WebSocket {url: "ws://127.0.0.1:9090/", readyState: 1, bufferedAmount: 0, onopen: ƒ, onerror: ƒ, …}transportLibrary: "websocket"transportOptions: {}_conf: {maxListeners: 0}_events: {maxListeners: 0, connection: ƒ, error: ƒ, close: ƒ, call_service:/rosapi/nodes:1: ƒ}__proto__: g
ros.getNodes(function(n){console.log(n)});
undefined
main.js:18 Connection to websocket server closed.
ros
d {socket: WebSocket, idCounter: 2, isConnected: false, transportLibrary: "websocket", transportOptions: {…}, …}event: "close"groovyCompatibility: trueidCounter: 2isConnected: falsesocket: WebSocket {url: "ws://127.0.0.1:9090/", readyState: 3, bufferedAmount: 0, onopen: ƒ, onerror: ƒ, …}transportLibrary: "websocket"transportOptions: {}_conf: {maxListeners: 0}_events: {maxListeners: 0, connection: ƒ, error: ƒ, close: ƒ, call_service:/rosapi/nodes:1: ƒ, …}__proto__: g
Here't the output from the terminal window
[INFO] [1542421699.375919]: Serving at 127.0.0.1:8080
registered capabilities (classes):
- rosbridge_library.capabilities.call_service.CallService
- rosbridge_library.capabilities.advertise.Advertise
- rosbridge_library.capabilities.publish.Publish
- rosbridge_library.capabilities.subscribe.Subscribe
- <class 'rosbridge_library.capabilities.defragmentation.Defragment'>
- rosbridge_library.capabilities.advertise_service.AdvertiseService
- rosbridge_library.capabilities.service_response.ServiceResponse
- rosbridge_library.capabilities.unadvertise_service.UnadvertiseService
[INFO] [1542421699.610645]: Rosbridge WebSocket server started on port 9090
127.0.0.1 - - [16/Nov/2018 21:28:37] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [16/Nov/2018 21:28:37] "GET /main.js HTTP/1.1" 200 -
127.0.0.1 - - [16/Nov/2018 21:28:38] code 404, message File not found
127.0.0.1 - - [16/Nov/2018 21:28:38] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [16/Nov/2018 21:29:25] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [16/Nov/2018 21:33:34] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [16/Nov/2018 21:33:34] "GET /main.js HTTP/1.1" 200 -
[INFO] [1542422015.325308]: Client connected. 1 clients total.
[INFO] [1542422020.249735]: Client disconnected. 0 clients total.
127.0.0.1 - - [16/Nov/2018 21:34:18] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [16/Nov ...
Am experiencing this same issue. Have you found any resolution?