-
I have employed the response to the client socket method as socket.to(sessionID).emit(txId); and I received the following error message. TypeError: socket.to is not a function. Everything I have read has said this is the appropriate way to send the response from the server to a specific client. Please HELP! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi! That's weird, the |
Beta Was this translation helpful? Give feedback.
-
I've tried the following "socket.to(sessionID).emit(txId);", "socket.emit(txId);", and "server.to(sessionID).emit(txId);". My client is a java machine and although I'm sending userInfo and points successfully using, "socketWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); " to Nodejs socket.io. I can only receive the txId if the method I'm using is socket.to(sessionID).emit(txId), but this crashes Nodejs. If I use socket.emit(txId) Java client running " socketReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));" never gets call or txId data. My environment for both the Java client and the NodeJS Server is Ubuntu Linux version 18.04. Here is my Node JS code
Edit by @darrachequesne: format |
Beta Was this translation helpful? Give feedback.
-
I have written a very minimal NodeJS stub to see if any of the code was interfering with "sockect.to' operating. Even in this minimal configuration, I am receiving the following error. Process exited with code 1 Here is the minimal code I used. const server = require('net').createServer(); server.on('connection', socket =>{ socket.to(sessionID).emit("Trying to send info to the client"); }); socket.setEncoding('utf8'); server.listen(9000, () => console.log('server is listening on port 9000')); |
Beta Was this translation helpful? Give feedback.
I've tried the following "socket.to(sessionID).emit(txId);", "socket.emit(txId);", and "server.to(sessionID).emit(txId);". My client is a java machine and although I'm sending userInfo and points successfully using, "socketWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); " to Nodejs socket.io. I can only receive the txId if the method I'm using is socket.to(sessionID).emit(txId), but this crashes Nodejs. If I use socket.emit(txId) Java client running " socketReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));" never gets call or txId data.
My environment for both the Java client and the NodeJS Server is Ubuntu Linux version 18.04.
Her…