Random WinError 10060 when trying to connect to websocket - python

Background - using a windows machine, Windows 10/11, connected to the internet through ethernet cable. Using python's websocket-client module, on pycharm.
Problem - one fine day, out of the blue, I am no longer able to connect to FTX's websocket wss://ftx.com/ws/ on my local windows machine and kept getting the error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I tried on my VPS, a linux machine, with the same exact code and it works fine.
Attempts to fix the problem were:
A full reformat of computer, windows 10 > windows 10, and reinstall python 3.10 and pycharm.
Then upgrading windows 10 > windows 11.
Made sure all drivers are up to date, and also reinstalling them.
Resetting network settings from Windows
Tested the websocket connection with other end point and it worked fine. eg wss://api.gemini.com/v1/marketdata/BTCUSD
None of the above worked.
My websocket connection is in a while loop something like this
while True:
try:
ws.run_forever()
time.sleep(0.2)
except:
pass
So it would keep retrying.
There was a weird behavior when, from windows, I disable, and re-enable the network adapter, the websocket connection would suddenly be successful. And if I were to disable and re-enable the network adapter again; sometimes it would continue to fail, or sometimes the connection would be successful again. Note this is while the code is still executing in the while loop.
And, if I were to stop and re-run the code, it would never work, and the error WinError 10060 would arise.
At this point I am stumped and have no clue how to solve this problem as it was totally random and out of the blue. Looking for help and advise please..!

Related

Mavproxy + mission planner + dronekit with no companion computer

I’m trying to connect mavproxy, mission planner and dronekit to my hexa.
i am not using a companion computer my setup is as follows:
i have a pc running windows for mission planner and on that same pc im running a virtual machine with ubuntu 16.04 running dronekit and mavproxy.
first I'm running mavproxy and forking out 2 connections, 1 for mission planner and one for dronekit with the following code:
mavproxy.py --master=/dev/ttyUSB0(I'm telling mavproxy to use the serial which the telemetry dongle is connected to) --baudrate=57600 --out=127.0.0.1:14551(ip address on my virtual ubuntu) --out=10.0.0.7:14550 (IP for my windows machine)
I am able to connect to the drone in mission planner via the UDP at port 14550. and I am able to send commands via mavproxy console such as change modes/arm etc.
my problem is when I execute my connect script from dronekit to connect to the drone I'm getting a timeout error.
the code
from dronekit import connect, VehicleMode, LocationGlobalRelative
import time
import argparse
parser = argparse.ArgumentParser(description = ‘commands’)
parser.add_argument(’–connect’)
args =parser.parse_args()
connection_string = args.connect
vehicle = connect(connection_string ,wait_ready=True)
when I open a new terminal I run the command to launch and connect drone kit
python connect.py --connect 127.0.0.1:14551
once I run this it gets stuck and after 30 seconds I get the following output:
dronekit.TimeoutError: wait_ready experienced a timeout after 30 seconds.
sometimes I get the following output:
gcs failsafe cleared
and then it gets stuck and after 30 seconds:
dronekit.APIException: Timeout in initializing connection.
I searched for about 3 days for solutions and tried everything that is out there pretty much, such as telling dronekit to wait longer than 30 seconds, but still, I get the same error.
I updated dronekit to the latest version, updated pymavlink and pyserial. also downgraded them to check if it will solve this but nothing works.
my main question is: is this error happening because dronekit can only run on a companion computer? and is not built for connecting threw telemetry radio?
if not, what am I doing wrong?
I sincerely am lost and praying that someone can help me.
thanks in advance. I would literally pay someone for a solution.
and again, sorry for the double post.

TCP server (Python) on Raspberry Pi bootup results in error: Address already in use

I have a TCP server created on a Python script, I want to execute it on Raspberry Pi boot up. I have put the Python script in .bashrc and it executes on the boot up, but it displays the following error:
s.bind(('', 5555))
socket.error: [Errno 98] Address already in use
I have created a TCP client on Matlab and the communciation works perfectly. I can manually execute the server from Raspberry Pi 3 command line send/recv data and close the socket, but even after properly closing if I restart my Raspberry Pi, on boot up it still displays the error.
I have also tried s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1), but I still get the error. I dont want to manually change the port number every time, therefore any help would be appreciated.
This message occurs when you try to use a port number that is already in use.
Because you start the server process with your .bashrc file, an attempt will be made to start it when your system boots, when you start a new shell, or when you ssh into the system.
This article makes some suggestions about other ways you could use.
Note that when you see this message, it comes from repeated attempts to start your server, but the good news is you should still be able to connect to the server - the message does imply it's already running.

Aborted connection error in flask

If the client closes an established connection that it has made with the flask server, I get the following error in the terminal:
[Errno 10053] An established connection was aborted by the software in your host machine
It seems when flask tries to write in the closed stream, it faces errors and hence will complain.
It seemed like a warning or so as the application does not quit after printing the error, but the problem is that my server will stop serving other requests despite being alive in the system.
I have read similar questions but they did not help. How can I prevent this issue? I use both Windows and Linux operating systems.
The cause of this problem is, as we previously discussed, insufficient permissions to perform the network operation. The remedy to the problem was to run the process as an administrator and/or to modify the system policy to allow connections on the restricted port.

Jupyter notebook: connection to kernel restarts infinitely

I just moved on to a new PC at work, installed Anaconda.
When trying to run a notebook I see the "connecting to kernel... connected to kernel" message flash to infinity with an icon saying "No connection to kernel".
It appears as if the connection gets killed after starting.
Gif: https://i.gyazo.com/6a36abdcc1c5af6e31b4666f4baef4cf.gif
Another person at work in my room has the same problem, so perhaps it has something to do with the antivirus or domain systems at work.
How can I get my jupyter to work?
Turn off the antivirus. In my case there was the Kasperskiy who was blocking the connection

PyCharm remote debugging (pydevd) does not connect

PyCharm remote debugging (pydevd) does not connect with the following message:
error: [Errno 10061] No connection could be made because the target machine actively refused it
How can I troubleshoot it?
The output console in PyCharm shows:
Starting debug server at port 21000
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('*.*.*.*', port=21000, suspend=False)
Waiting for process connection...
Server stopped.
I checked the firewall and PyCharm is allowed for both incoming and outgoing connections.
10061 is WSAECONNREFUSED, 'connection refused', which means there was nothing listening at the IP:port you tried to connect to.
Though I see that you have validated its not a firewall issue, but still I would suggest to check the port numbers again with respect to the ones opened in windows firewall. Or to narrow down just run a simplehttpserver or icmp server at the same port and confirm.
In a direct link communication, it often means that you have already something connected to this port.
To check what process is hearing what port, check this SO question.
You can then either kill the program or change the port, depending of what you can do.
Without more information of the "remote tested", it is hard to know what is happening.
I was having the trouble as well (Server stopped as soon as the client connected).
Turned out that I had apparently too many breakpoints defined.
after having removed most of them and re-initiated my remote debug connection from the client (and having restarted the debug server in pycharm) it doesn't trigger anymore the "Server stopped." problem.

Categories

Resources