Python socket not accepting port as variable from api -
i running socket script wait connection using port number api response
seleniumport = cont["ports"][0]["publicport"]
i converting int using function i'm passing socket errors
client.connect(('192.168.33.10',seleniumport)) socket.error: [errno 111] connection refused
econnrefused (111)
connection refused. error can occur during attempt connect tcp socket. reported when reset or unexpected sync message received.
i pretty sure going have put in try
loop , wait other end listening.
edit:
comments going have print out seleniumport @ same time have port number program supposedly listening check identical each time.
arguably, testing adding let's 10 port number should give identical error, ie nothing listening on other end.
short of that, create script listen on given port , test against i.e.
import os, socket, time address = ('localhost',32840) s = socket.socket(socket.af_inet, socket.sock_stream) s.bind(address) s.listen(1) sc, client_address = s.accept() while true: print ("connection made ", client_address) n = 1 try: data_recv = sc.recv(4096) if len(data_recv) > 0: print ("received ", data_recv,n) except: print ("disconnect") break
try running , connection challenged code connect or run like:
import socket s = socket.socket(socket.af_inet, socket.sock_stream) address = ('localhost',32840) s.connect(address) s.sendall('mystuff')
Comments
Post a Comment