question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

data strings changes over socket

See original GitHub issue

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

  • report a bug
  • request a feature

Current behaviour

when emitting an object as data and within it using a string of (or the unicode \u2265) it turns it to the string letter e and trurns to d

Steps to reproduce (if the current behaviour is a bug)

client side

channel.emit('data', {data:'≥'});

server side

socket.on('data',({data:bla})=>{
console.log(bla); // prints 'e'
});

Note: the best way to get a quick answer is to provide a failing test case, by forking the following fiddle for example.

Expected behaviour

that the data will stay the same consistently

Setup

  • OS: Windows
  • browser: Chrome 62
  • socket.io version: 1.7.2

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
deanshubcommented, Dec 6, 2017

tried it with 2.0.4, still happens… fixed it with encoding and decoding the data with this code: client side

function strencode( data ) {
	return encodeURIComponent( escape( JSON.stringify( data ) ) );
}

server side

function strdecode( data ) {
	return JSON.parse( unescape( decodeURIComponent( data ) ) );
}
1reaction
yotamgevercommented, Dec 6, 2017

Yeah that’s seems to be working. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

string in variable changes before sending through socket
I have the following scenario, a two socket connection (one acts as a server and the other one as a connection to a...
Read more >
Node.js v19.3.0 Documentation
Example: sending a server object; Example: sending a socket object ... Non-backward compatible changes or removal may occur in any future release.
Read more >
Writing WebSocket client applications - Web APIs | MDN
These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols (for example, ...
Read more >
socket — Low-level networking interface — Python 3.11.1 ...
A string or bytes-like object can be used for either type of address when passing it as an argument. Changed in version 3.3:...
Read more >
Writing the Server Side of a Socket (The Java™ Tutorials ...
The accept method waits until a client starts up and requests a connection on the host and port of this server. (Let's assume...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found