我在Python中创建了一个TCP套接字监听程序。现在我正在尝试在Heroku上执行它。
Procfile:
worker: python server.py jobs:work
Server.py:
def start_server():
server_config = config['Server']
# configurations
HOST = server_config['HOST']
PORT = int(environ.get('PORT')) #server_config.getint('PORT')
BUFFER_SIZE = server_config.getint('BUFFER_SIZE')
# server socket setup
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind((HOST, PORT))
server_socket.listen(server_config.getint('LIMIT'))
logging.info('server started %s:%d', HOST, PORT)
CLI:
F:\dev\>heroku run python server.py
Running python server.py on syswow64server... up, run.3213 (Free)
INFO:root:server started 0.0.0.0:14150
我知道Heroku使用内部端口映射网格,因此内部的14150端口不会映射到外部的14150端口。那么我该如何向服务器发送请求?要使用哪个端口呢?
我尝试了在80和443端口发送请求,但似乎它们没有映射到14150端口。