Difficulty connecting socket to a webserver

Hi All,

I’ve have a question concerning the socket class.
I want to send data from the zerynth device to a webserver (apache2).

I’m using the socket class to connect to the webserver, but I receive an error:

Trying to connect to webserver…
[ERROR: requests: TypeError @[008C:008D:0098:0047:0000:006D:0000:0000]](javascript:window.except(’@[008C:008D:0098:0047:0000:006D:0000:0000]’,'ERROR: requests: TypeError '))
Server did not respond.

The first and last line are the output of two print statements. The error url point to the “s.send(…” code line. Therefore the socket is created and connected.

Just for background info, the device has a wifi connection up and running, and I do receive print data via an UDP stream for debugging.
That said, could it be an error because two sockets are open?

The code executed is:

myPrint(“Trying to connect to webserver…”)
s = socket.socket()
s.connect((host, port))
s.send(bytes(‘GET /page.php?a=’ + a + ‘&b=’ + str(b) + &c=’ + c + ’ HTTP/1.1\r\nHost: www.’ + name + ‘.com\r\n\r\n’, ‘utf8’))
sleep(1000) # Just wait a bit for the server responce
data = s.recv(500) # Check to server’s responce message
except Exception as e:
myPrint('ERROR: requests: ’ + str(e))
sleep(500) # Just wait a bit for the server responce
finally:
s.close()

Can someone explain why this isn’t working. The documentation isn’t very clear on how to setup such a connection.

Best regards,
lvx_xvl

Have you checked the example in the sockets documentation ?
https://docs.zerynth.com/latest/reference/core/stdlib/docs/socket/#the-socket-class