Giter Site home page Giter Site logo

Comments (8)

sumit-chavla-hra avatar sumit-chavla-hra commented on August 16, 2024

My Login Function

async def login(self, attempts=5):
        print('IN [login]')
        check, reason = await self.client.connect()
        if check:
            print(datetime.now(), " Successfully reconnected!!!")
        else: 
            print(datetime.now(), "Failed to connect")
        attempt = 1
        print(colored("[INFO]: ", "blue"), "Connecting...")
        while attempt <= attempts:
            if not self.client.check_connect():
                print(colored("[INFO]: ", "blue"), f"Trying to reconnect, try {attempt} for {attempts}")
                check, reason = await self.client.connect()
                if check:
                    print(datetime.now(), " Successfully reconnected!!!")
                    break
                print(colored("[INFO]: ", "blue"), "Error reconnecting", reason)
                attempt += 1
                if os.path.isfile(".session.json"):
                    os.remove(".session.json")
            elif not check:
                attempt += 1
            else:
                break
            await asyncio.sleep(0.5)
        print('OUT login')
        return check, reason

Modified on_close function of quotexpy.ws.client

def on_close(self, wss, close_status_code, close_msg):
        logger.debug("IN [on_close] function")
        """Method to process websocket close."""
        logger.info("Websocket connection closed.")
        print(datetime.now(), " Close Reason: ",close_status_code, close_msg)
        global_value.check_websocket_if_connect = 0
        logger.debug("OUT [on_close] function")

Terminal logs
Screenshot 2023-12-26 at 11 48 38 AM

I found that after some time on_close is getting called automatically, how can I prevent that? also it is showing close_status_code and close_msg as None that's why I am kind of unable to figure out cause of auto close endpoint :(

from quotexpy.

ricardospinoza avatar ricardospinoza commented on August 16, 2024

I uploaded the latest version implementing the singleton design pattern for single connections. Can you confirm if the problem continues to occur?

from quotexpy.

sumit-chavla-hra avatar sumit-chavla-hra commented on August 16, 2024

Can you please tell me how I can take advantage of your singleton pattern, I cannot find it.

from quotexpy.

ricardospinoza avatar ricardospinoza commented on August 16, 2024

from quotexpy.

sumit-chavla-hra avatar sumit-chavla-hra commented on August 16, 2024
Screenshot 2023-12-26 at 9 38 34 PM still getting connection closed automatically after around 15 seconds

from quotexpy.

sumit-chavla-hra avatar sumit-chavla-hra commented on August 16, 2024

I have found that the connection is being closed due to "pingInterval":25000,
To fix this I have created a thread(in quotexpy.ws.client.on_open function) that will ping after every pingInterval time to keep the connection alive and I am sending random messages since I don't know any smaller messages which I can use to keep the connection alive with minimum network IO

Here is message I am sending each ping interval to keep the connection alive
self.wss.send('42["instruments/update",{"asset":"EURUSD","period":60}]')
I feel it is not a right message that can be used to ping was to keep alive please suggest to me right solution for it,
Please throw some light If I am doing anything wrong here

from quotexpy.

ricardospinoza avatar ricardospinoza commented on August 16, 2024

monitoring the socket, the ping time is actually at 25000, but the response on_pong is sending is the value "2"

from quotexpy.

github-actions avatar github-actions commented on August 16, 2024

This issue is stale because it has been open for 30 days with no activity.

from quotexpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.