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.

How to maintain long or reuse connection

See original GitHub issue

I have been trying to maintain connection btw client and server like heartbeat checkup. When I run the program for the first time the ping is working in the server with status **** connect but after the 1st iteration when the emit function is called but emit is not working with statue **** disconnect.

# version: 1
from socketio import Client, 
ws = Client()
ws.connect(f'http://localhost:5000/')

white True:
    ws.emit('to_server', 'Ping')
    ws.sleep(5)

Expected Result

I like to invoke recver the message to the server, each time on the iteration on calling emit in client side.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jawahar273commented, Jul 8, 2019

Sorry about that. Thanq for your time.

0reactions
miguelgrinbergcommented, Jul 7, 2019

As I said above, you are disconnecting after you send each event. Your actual code is different than the snippets you are showing me here. You have a try/except/finally, and you are disconnecting in the finally clause.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reusing backend connections to increase performance - Fastly
Reusing connections between your Varnish instance and your backends (origins) is a good idea for multiple reasons.
Read more >
4 Optimizing Universal Connection Pool Behavior
The connection reuse feature allows connections to be gracefully closed and removed from a connection pool after a specific amount of time or...
Read more >
Load balancing and scaling long-lived connections in ...
Kubernetes doesn't load balance long-lived connections and some Pods ... HTTP keep-alive, or HTTP connection reuse that uses a single TCP connection to...
Read more >
Improve database performance with connection pooling
Instead of opening and closing connections for every request, connection pooling uses a cache of database connections that can be reused ...
Read more >
How To Reuse Http Connections In Go - Golang Cafe
In this article we are going to see how it's possible to reuse http Connections In Go and how you can do it....
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