The problem I am trying to solve is
I can communicate to the client via REST and separately I can communicate to the external server via socket (response time is ~100ms). But combining these results yields nothing.
const sjsc = require('sockjs-client');
app.post('/form', function(req, res) {
const srvc = sjsc('http://external.server:port/path');
srvc.onopen = function () {
srvc.send(testData);
}
srvc.onmessage = function(data) {
console.log('received ', data);
res.send(data);
};
});
const srvc = sjsc('http://external.server:port/path');
this needed to be a let
. this is the only thing i changed and works perfectly.
let srvc = sjsc('http://external.server:port/path');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.