socket.io-client-cpp icon indicating copy to clipboard operation
socket.io-client-cpp copied to clipboard

It keeps disconnecting and reconnecting then failed with json parsing (nothing sent)

Open dzpt opened this issue 8 years ago • 1 comments

sio::client h;
h.connect("http://127.0.0.1:3000");

On the server, i do nothing. Nothing to emit.

Here is the error after repeatly disconnect and reconnect.

node app.js
1Vly7u40VqO6yHv9AAAA connected
1Vly7u40VqO6yHv9AAAA has disconnected
02BMR0VXIONF6xqOAAAB connected
02BMR0VXIONF6xqOAAAB has disconnected
ONttZcuc8ATmpnRWAAAC connected
ONttZcuc8ATmpnRWAAAC has disconnected
UQAnceNZxU1T3vaBAAAD connected
UQAnceNZxU1T3vaBAAAD has disconnected
screen shot 2017-06-29 at 6 31 54 pm

dzpt avatar Jun 29 '17 16:06 dzpt

I have very simmilar issue - constant, immediate disconnect from server after client connects.

I found the reason after a bit of confusion - it seems that when you use rapidjson in your own code, then there happens to be some mismatch with the version provided by socket.io-client-cpp (in lib directory). On @dzpt screen there is very similar line asserting in: .../json/document.h which looks like a path to your local rapidjson.

In my case the error sometimes manifests itself as a aseertion failure and mainly just as permanent disconnections. I even tried moving all code that uses rapidjson to separate cpp, but it doesn't help. For some reason just creating a Document anywhere causes everything to blow up:

rapidjson Document d;

though pointer for example works ok:

rapidjson::Pointer p;

So for now I don't have any way to use rapidjson in my code.

(setup: cmake build on MSVC14 -> lib + static linking to my app)

Miosss avatar Oct 22 '21 10:10 Miosss