【问题标题】:Socket IO - how to configure and connect to netty socket io server on a secure domainSocket IO - 如何配置和连接到安全域上的 netty socket io 服务器
【发布时间】:2018-03-10 10:40:25
【问题描述】:

我需要一些关于通过 https 进行 netty socket io 的帮助。我已经将它放在我的本地环境中,但没有放在具有安全域的服务器上。服务器启动,但客户端无法连接。尝试使用 IP 和域名启动套接字服务器。为了让服务器在 setHostname 方法中以域名作为主机名值开始,我在 /etc/hosts 文件中添加了一个条目,如下所示

127.0.0.1 本地主机 example.com

通过将 example.com 作为主机名来启动套接字服务器,但客户端无法通过 https 使用相同的主机名进行连接,如下所示

var socket = io.connect('https://example.com:10443')

尝试使用选项 - { secure: true, reconnect: true, rejectUnauthorized : false } 但同样的问题。

在服务器端我的配置如下

Configuration configuration = new Configuration();
configuration.setHostname("example.com");
configuration.setPort(10443);
configuration.setKeyStorePassword("mypassword");
InputStream stream = getClass().getClassLoader().getResourceAsStream("keystore.jks");
configuration.setKeyStore(stream);

jsk 文件是使用 keytool 命令为同一域 (example.com) 创建的

对于要被套接字服务器使用的端口 - 10443,是否还有更多工作要做?或者还有什么其他的配置要做吗?

【问题讨论】:

    标签: java ssl https socket.io


    【解决方案1】:

    找到解决方案!我没有提到该域是在 cloudflare 上设置的。这里的问题在于我使用的端口 - 10443。cloudflare 不支持它。将其更改为 8443 并且有效!

    对于遇到此问题的人,请查找 here Cloudflare 使用的受支持端口列表。与我不同,可能会节省您的大部分时间。

    另外,请注意我在 setHostname() 方法中使用了我的公共 IP 作为主机名,因此我不需要在我的主机文件中添加任何内容。然后在客户端使用 https 提供实际域名以连接到服务器。而已。谢谢大家!

    桑迪普

    【讨论】:

      猜你喜欢
      • 2020-04-28
      • 2022-09-27
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 2012-12-16
      相关资源
      最近更新 更多