websocket connection goes to unknown state - python

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.

Related

Ngrok as portforwarding in python socket not connecting

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

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.

RTMP Connection Timeout in Python

we created a RTMP server using NGINX and have a camera that is streaming video to that server. We have a python program that should connect to the RTMP server and then display the video on the computer. When we run the program we keep getting the below error:
RTMP_Connect0, failed to connect socket. 110 (Connection timed out)
I found a RTMP url on that was used for testing the code and it works but our RTMP server doesnt. Does anyone know of any settings that need to be set to be able to get passed this error?
Firstly I would check your firewall, TCP port 1935 needs to be open.

Raspberry Pi python app and nodejs socketio communication

My requirement is to communicate socketio with nodejs server to Raspberry Pi running a local Python app. Please help me. I can find ways of communication with web app on google but is there any way to communicate with Python local app with above mentioned requirements.
It's unclear exactly which part you need help with. To make a socket.io connection work, you do the following:
Run a socket.io server on one of your two computers. Make sure it is listening on a known port (it can share a port with a web server if desired).
On the other computer, get a socket.io client library and use that to make a socket.io connection to the other computer.
Register message handlers on both computers for whatever custom messages you intend to send each way and write the code to process those incoming messages.
Write the code to send messages to the other computer at the appropriate time.
Socket.io client and server libraries exist for both node.js and python so you can either type of library for either type of system.
The important things to understand are that you must have a socket.io server up and running. The other endpoint then must connect to that server. Once the connection is up and running, you can then send message from either end to the other end.
For example, you could set up a socket.io server on node.js. Then, use a socket.io client library for python to make a socket.io connection to the node.js server. Then, once the connection is up and running, you are free to send messages from either end to the other and, if you have, message handlers listening for those specific messages, they will be received by the other end.

Python connection to server and interact with database

I have question how can I connect to VPS server and interact with MySQL database using python on my local machine.
I would like to make program using PyQT that connect to my server and update, take sth from db.
I know that there is MySQLdb module but from what I know i cannot connect to VPS server, because in connect method it doesn't take server password argument.

Categories