I am trying to connect to an AWS instance using python socket connection. The AWS server is receiving the first handshake and tries to reply. On the Anvil part this message is not coming through resulting in a timeout.
I have tested the same connection from a local Python script and it is working fine. What could be the reason that the inward messages to Anvil are not coming through?
python
import anvil.server
from datetime import datetime
import socket
import time
import threading
import comfunct as CF
import shared as SH
socket variables
HOST = âxxxxxâ # The serverâs hostname or IP address
PORT = xxx# The port used by the server
global encoding
encoding = âutf-8â
curr_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@anvil.server.callable
def open_socket():
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
print(local_ip)
print(âCLIENT: ik open nu de verbindingâ)
IPAddr = socket. gethostbyname(hostname)
curr_sock.connect((HOST, PORT))
global data
data = curr_sock.recv(4096)
while True:
global data_con_code
global msg
global full_msg
global mess_eval_1
global mess_eval_2
full_msg = ""
new_msg = True
msg = curr_sock.recv(4096)
funct_dict = {
"asa_mes": "CF.asa_mes",
"asa_question": "CF.asa_question",
"asa_questionyn": "CF.asa_questionyn",
"internmes": "CF.internmes",
"grenzen": "CF.grenzen",
"startup": "CF.start_up",
"next_exercises": "CF.add_exercises",
"report": "CF.report",
"close_ASA": "CF.close_student"
}
if new_msg:
full_msg += msg.decode(encoding)