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
Related
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
I am new to python socket programming and was following a tutorial building a chat-app, using kivy and sockets. I am running my server on my main PC and I was trying to connect from my laptop to this Server, but it doesn't work (Both my PC and laptop are connected via Ethernet cable). When I run the client.py on the PC that I host my Server on, everything works fine.
I tried running the Server on my 0.0.0.0 address and then connecting from my laptop to the IP address that appears on my Server PC if I type in "ipconfig" (192.168.2.x) but it didn't work. I also tried running the server just on the Ethernet-Adapter IP that appears when I type in "ipconfig" (so 192.168.2.x) but this doesn't work neither.
Lastly I have tried defining my Server IP by using the built in socket function: socket.gethostbyname(socket.gethostname()) (weirdly when I run this, my Server runs on my VMware Network Adapter (192.168.66.x) instead of my Ethernet-Adapter). But this too didn't work :(
The client.py code on my laptop always returns this error:
connection 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
Would appreciate any help :)
edit: Could this have something to do with the firewall on my PC blocking connections or something?
Found the Problem! Today it actually worked by disabling my host PCs Windows Defender internal Firewall and the running the Server on 0.0.0.0, which is very weird because yesterday it didn't work...
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.
I am attempting to run a python script on a localhost server in order to interact with this script from other terminal windows.
I know there is no fault in the python script as this exact method of connection works on a different machine.
First, I run the following in Terminal Window 1: python ./myserver.py localhost 8080 - my script gives me a message saying that the server script has successfully started.
Second, using Terminal Window 2 I attempt to connect to this localhost via Telnet using the following: telnet localhost 8080 - this is where my error lies. Immediately after I enter the command I receive the following message,
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
How can I fix or at least troubleshoot this problem?
Thanks to VIPIN KUMAR for this suggestion.
I needed to restart the xinetd service as the telnet service was not running correctly.
Here is what I am trying to do. I have a Windows VM and another Linux VM which is used as server. I have Spyder installed on my Windows VM and would like to run my Python code in Spyder on remote Linux server.
I did try using option in Spyder called "Connect to remote kernel" but it did not work and I am getting error "Could not open ssh tunnel ; Paramiko not available". I was using username#servername:22 for making ssh connection. Needless to say, I am able to ssh the machine using putty but not using Spyder. Any ideas how should I fix this?
I found another way to make a connection to an external server, here is the link explaining step by step.
Basically, you have to connect your client PC to the server through a PuTTY SSH tunnel, it will allow to redirect the client ports to the correct ipython kernel server ports.