Open VorpalBlade opened 5 years ago
How do you know "roslib did not pick this up". What error did you get?
Did you get the following message? throw 'Cannot process BSON encoded message without BSON header.';
No, I did not get that message. What happened is that I got a message that it managed to connect the web socket (from ros.on('connection', ...
). Then nothing (except the errors on the server side from rosbridge_server as described above). If I disable bson_only_mode subscriptions go through and everything works.
This was the behaviour both with and without the bson = require('bson')
line or not. As well as when I replaced the optional check in SocketAdapter.js with a hard dependency on bson.
@Rayman I think what @VorpalBlade was talking about is that the SocketAdapter.js
file looks for an global variable bson
(which is barely documented anywhere) here:
If that variable exists (presumably from the bson
package, one would assume, as it is not documented), then SocketAdapter
will use it.
I'm catching errors like 'bson' is not defined
now that I'm running ESLint on the source while working on https://github.com/RobotWebTools/roslibjs/pull/475.
@VorpalBlade What you would have to do it set bson
as a global in Node.js:
global.bson = require('bson');
The version you wrote using const
does not create a global variable, therefore roslib
does not see it.
Ah, I need to add a shim file for bson
in #475. Documenting it would be nice.
I'm interested in running with BSON only mode on the rosbridge side. However I can't figure out how to make this work, as I get errors like this (and no data passed):
I have added the bson module (I'm using webpack currently to generate the client side javascript, since the ready made browser bundle file did not work for bson).
It does not seem like roslib picks this up. Nor does it help modifying roslib to have it as a hard dependency in SocketAdapter.js. Any advice on how to get this working would be useful.