【问题标题】:Tornado secure websocket timeoutTornado 安全 websocket 超时
【发布时间】:2016-07-01 17:42:05
【问题描述】:

我的服务器有 2 个 IP (ip1 & ip2) 我最近添加了 ip2。当我尝试在 ip1(apache2 正在运行)上打开我的 tornado websocketserver 时,一切都很好,我指定了一个端口,例如22000,可以通过wss://domain.tld:22000/sub连接到我的socket

但是,一旦我将 tornado 配置为侦听 ip2(apache 未运行),因为我必须使用 ip1 上的 apache 阻止的端口 443,我不能通过wss://sockets.domain.tld:443/sub 连接到它。 DNS A 记录指向 ip2。

连接超时。无论我使用哪个端口或协议(wss / ws)。


我的python代码:

from tornado import web
from tornado import ioloop
from tornado import websocket
from tornado import httpserver
import ssl
import json
import random
import re
import os

application = web.Application([(r"/sub", Client)])
http_server = httpserver.HTTPServer(application,  ssl_options = {
    "certfile": os.path.join(LIB_DIR, "certificate.crt"),
    "keyfile": os.path.join(LIB_DIR, "certificate.key"),
})
http_server.bind(443, address = "ip2")
print("Listening to ip2:443")
ioloop.IOLoop.current().start()

我的服务器在Ubuntu 12.2 上运行,我打开了端口并使用外部工具检查它们是否打开。

我该如何解决这个问题?和我的服务器有关吗?

更新 我很确定它与http_server.bind(...) 有关,代码确实适用于.listen(port),但ip1 和bind 也不起作用。

【问题讨论】:

    标签: python sockets ubuntu tornado iptables


    【解决方案1】:

    根据the documentation,在调用bind之后,你应该在服务器上调用start。所以

    http_server.bind(443, address = "ip2")
    print("Listening to ip2:443")
    http_server.start()
    ioloop.IOLoop.current().start()
    

    应该可以。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-22
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 2012-09-04
      • 1970-01-01
      相关资源
      最近更新 更多