Ngrok as portforwarding in python socket not connecting - python

I have a problem where the socket client wont connect to the server in python when using ngrok. Only if i run the server before starting the client it works. Also the client wont detect when server looses connection anymore. I think the client detects ngrok as a server without the python server running

Related

Client can't connect to websocket server using servers ip

I'm building a home automation project, I have a websocket server I've built with pythons websocket and asyncio libraries. When I use a python client testing script and use local host to connect, it works perfectly. However, when I use my computers IPv4 address it doesn't. I've tried connecting using esp's, raspberry pi's and the same testing script on the same computer. Any idea's?

Python rpyc run in background

I am using rpyc to create a Service (server). I was able to do this. Now I'm I would like to run it and connect to it using my client.
I run the server
python3 myserver.py
This runs fine. Then I run the client
python3 myclient.py
The problem is I get an error:
ConnectionRefusedError: [Errno 61] Connection refused
When I run myserver.py from Anaconda Spyder, them my client works fine, but when I run my server from the shell or command prompt, it says connection refused. Is there a specific way I need to run a rpyc server in order to connect to it?
First, check your firewall - is it open for RPyC server port
Also make sure your server uses for binding address 0.0.0.0 and not localhost (127.0.0.1)
Very important to ensure that both server and client use the same Python and RPyC versions

When stopping SSHTunnel server the application hangs

I have very simple script that establishes connection to another host and then creates the tunnel through which another application connects to SQL Server.
self.dicSession['server'] = sshtunnel.SSHTunnelForwarder(
('remote_host', 22),
ssh_username="username",
ssh_password="password",
ssh_private_key="key_rsa",
remote_bind_address=('remote_host', 53425),
local_bind_address=('localhost', 1433),
)
self.dicSession['server'].start()
It works fine. However the command to stop the server. When the connection is established I am using tunnel (between 53425 port of remote host and 1433 port of localhost) to connect to a SQL Server that operate on the remote host. Up to this point everything works fine. It seems however that stopping the SSH connection with command
self.dicSession['server'].stop()
does not work properly. Despite the command to stop the connection I am still able to execute SQL statement and get results. Moreover when I execute the SQL query after the command
self.dicSession['server'].stop()
the app - which us build with usage of PyQT5 - freezes. To be honest I have not tried to run the script without GUI but I will need the GUI as the app is not only for me but for other people who are not familiar with CLI.
This happens because your client is still open.
It will allow you to stop server, once you closed your client.

socket recv hangs forever or timeout

I'm using rpyc package to communicate between server and client. Everything was worked fine until today. My client pc can't receive message from server. So I run socket server:
$ python bin/rpyc_classic.py
INFO:SLAVE/18812:server started on [0.0.0.0]:18812
Connect like in docs:
import rpyc
conn = rpyc.classic.connect("10.99.100.200")
I tried to debug with wireshark, firewall is off and all is worked before. I'm using OSX. When I do reverse, connection working fine

websocket connection goes to unknown state

I have a web server running on ubuntu instance at Amazon EC2.
My web server is written in Python and supports WebSockets.
My Problem:
I am able to connect to my server through websocket and I am also able send and receive data over websocket. However, after few minutes if I try to send data on same connection from client application I am not receiving anything on server for the same established connection. Now if I close the client application or try to connect through another client application, I am able to connect and communicate again for few minutes only. And after few minutes the new connection again faces the same issue. Please help me to solve the issue.
Of course, when I run the server on my local testing environment the connection never dies and I can communicate over same websocket connection after hours also.

Categories