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

FB closing connection after around minute despite ping-pong. #3

Open
JabLuszko opened this issue Aug 2, 2024 · 3 comments
Open

FB closing connection after around minute despite ping-pong. #3

JabLuszko opened this issue Aug 2, 2024 · 3 comments

Comments

@JabLuszko
Copy link

JabLuszko commented Aug 2, 2024

Quick log.
The handshake data seems to be correct comparing to my browser.
This is (re-)using cookies from webbrowser, but I made sure that it was closed for like 60 minutes if FB couldn't handle sessions or something.

Any idea what is happening? I've fiddled with intervals (up to 8 seconds) and socket timeouts - FB still closes connection.

Fri Aug  2 02:52:44 2024 INFO Setting configs.needSync to true
Fri Aug  2 02:52:48 2024 INFO Loaded versionId & appId appId=2220391788200892 versionId=7940365299384809
Fri Aug  2 02:52:48 2024 INFO Configs successfully setup! broker=wss://edge-chat.facebook.com/chat?region=odn
Fri Aug  2 02:52:48 2024 DEBUG Dialing socket broker=wss://edge-chat.facebook.com/chat?region=odn&cid=YYYYYYYYYYYYYYY&sid=XXXXXXXXXXXXXXXXXXXXX
Fri Aug  2 02:52:49 2024 INFO Client is ready! connectionCode=CONNECTION_ACCEPTED isNewSession=false
Fri Aug  2 02:52:49 2024 INFO Starting handshakeInterval...
Fri Aug  2 02:52:57 2024 DEBUG Sending handshake data to socket hex="c0 00"
Fri Aug  2 02:52:57 2024 INFO Sent handshake to socket
Fri Aug  2 02:52:57 2024 INFO Got PingResp packet
Fri Aug  2 02:53:05 2024 DEBUG Sending handshake data to socket hex="c0 00"
Fri Aug  2 02:53:05 2024 INFO Sent handshake to socket
Fri Aug  2 02:53:05 2024 INFO Got PingResp packet
Fri Aug  2 02:53:13 2024 DEBUG Sending handshake data to socket hex="c0 00"
Fri Aug  2 02:53:13 2024 INFO Sent handshake to socket
Fri Aug  2 02:53:13 2024 INFO Got PingResp packet
Fri Aug  2 02:53:21 2024 DEBUG Sending handshake data to socket hex="c0 00"
Fri Aug  2 02:53:21 2024 INFO Sent handshake to socket
Fri Aug  2 02:53:21 2024 INFO Got PingResp packet
Fri Aug  2 02:53:29 2024 DEBUG Sending handshake data to socket hex="c0 00"
Fri Aug  2 02:53:29 2024 INFO Sent handshake to socket
Fri Aug  2 02:53:29 2024 INFO Got PingResp packet
Fri Aug  2 02:53:37 2024 DEBUG Sending handshake data to socket hex="c0 00"
Fri Aug  2 02:53:37 2024 INFO Sent handshake to socket
Fri Aug  2 02:53:37 2024 INFO Got PingResp packet
Fri Aug  2 02:53:45 2024 DEBUG Sending handshake data to socket hex="c0 00"
Fri Aug  2 02:53:45 2024 INFO Sent handshake to socket
Fri Aug  2 02:53:45 2024 INFO Got PingResp packet
Fri Aug  2 02:53:51 2024 INFO Socket was closed. code=1000 text=Bye
@0xzer
Copy link
Owner

0xzer commented Aug 3, 2024

Not sure, haven't worked on this repo for a while and I don't have any plans on continuing it. Are you using a proxy? If it's consistently disconnecting after 8 seconds it would seem... weird? Maybe it's your connection? How are you using the library? Is your main program loop constantly running?

@JabLuszko
Copy link
Author

JabLuszko commented Aug 3, 2024

It's not disconnecting after 8 seconds - it takes around 1 minute from the start. / 8 second was note for me fiddling (decreasing) timer for PINGREQ just to make sure it's not hitting some funny 0.0002 seconds something edge-case/

Main program loop is running - it's not that. Plus it's FB servers closing connection - that 1000 Bye comes from them, isn't it?
It's like that PINGREQ is not working... but there are PINGRESP? On the other hand that PINGRESP can be generate by sending anything - I've messed with a structure for testing and it was still giving PINGRESP even for some crazy packets :|

No proxy, no magic - direct connection.

Also if I send some chat messages while this connection last for that 1 minute it does not extend the 1 minute thing - I would assume chat messages should extend the time as connection is active or FB don't care about that and PING is everything?
This also would suggest it's not some websocket internal (client side) timeout as those chat messages are getting sent and showing up.

msgBuilder := cli.Threads.NewMessageBuilder(threadId)
(...)
tableResp, err := msgBuilder.Execute()

If this is kinda abandoned do you know any other lib [whatever lang] that works with lightspeed thing for FB chat?

@0xzer
Copy link
Owner

0xzer commented Aug 4, 2024

I never had this issue, but I have heard of it before.

You can check out the updated messagix library (forked from this, not maintained by me) here.

Otherwise you can try to debug the issue by comparing the socket payloads in the library vs web connection, there is most likely something small that is different which you are missing

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

No branches or pull requests

2 participants