Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run problem:JSON parse error #27

Open
dxd39 opened this issue Dec 22, 2017 · 2 comments
Open

run problem:JSON parse error #27

dxd39 opened this issue Dec 22, 2017 · 2 comments

Comments

@dxd39
Copy link

dxd39 commented Dec 22, 2017

I tried to run the connection Demo, then meet a problem:
ArgumentException: JSON parse error: The document root must not follow by other values.

the json data revived like this: {"sid":"eADGfUhZX4r8EixPAAAB","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}2:40

so I change the code in class SocketInitializer from:
var textIndex = www.text.IndexOf('{'); if (textIndex != -1) { var json = www.text.Substring(textIndex); var answer = JsonUtility.FromJson<PollingUrlAnswer>(json); _urlQueries.Add("sid", answer.sid); }

to
var textIndex = www.text.IndexOf('{'); if (textIndex != -1) { int lastIndex = www.text.LastIndexOf('}'); int length = lastIndex - textIndex + 1; var json = www.text.Substring(textIndex, length); var answer = JsonUtility.FromJson<PollingUrlAnswer>(json); _urlQueries.Add("sid", answer.sid); }

then the problem has been solved

@ppz0th
Copy link
Contributor

ppz0th commented Dec 26, 2017

@dxd39 I think that you're running the server on Socket.IO V2 which is not supported yet. Please check your Socket.IO version and downgrade V1 if possible~

@yan-sandbox
Copy link

@ppz0th can I use support-socket.io-v2 branch for socket.io v2 already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants