简体   繁体   English

无法使用 react native/expo 连接到 SSL 连接到 socket.io

[英]Cant connect to socket.io with an SSL connection using react native/expo

For some very weird reason my android react native app is not connecting to socket.io over https. However when I use a tunnel program like ngrok or when i use http it works perfectly fine.由于一些非常奇怪的原因,我的 android 反应本机应用程序未连接到 socket.io 而不是 https。但是,当我使用像 ngrok 这样的隧道程序时,或者当我使用 http 时,它工作得很好。 I am using a valid SSL connection from sectigo and its still not connecting.我正在使用来自 sectigo 的有效 SSL 连接,但它仍然无法连接。

If anyone can help me fix this issue I would really appreciate it!如果有人可以帮我解决这个问题,我将不胜感激!

There are a few things you can try to troubleshoot the issue with your React Native app not connecting to socket.io over HTTPS:您可以尝试一些方法来解决您的 React Native 应用程序无法通过 HTTPS 连接到 socket.io 的问题:

Verify that the SSL certificate is valid and properly installed on the server.验证 SSL 证书是否有效并正确安装在服务器上。 Make sure that the certificate is signed by a trusted authority and that the server is configured to use the correct certificate.确保证书由受信任的机构签署,并且服务器配置为使用正确的证书。

Check the server's firewall settings to make sure that it is configured to allow incoming connections on the correct port (usually 443 for HTTPS).检查服务器的防火墙设置以确保它被配置为允许在正确的端口(对于 HTTPS 通常是 443)上的传入连接。

Make sure that the React Native app is configured to connect to the server over HTTPS. This may involve setting the appropriate protocol (https://) in the connection URL and adding any necessary security settings, such as the certificate or truststore.确保 React Native 应用程序配置为通过 HTTPS 连接到服务器。这可能涉及在连接 URL 中设置适当的协议 (https://) 并添加任何必要的安全设置,例如证书或信任库。

Check the.network connectivity between the client and server.检查客户端和服务器之间的网络连接。 Make sure that there are no firewalls or other.network-related issues blocking the connection.确保没有防火墙或其他与网络相关的问题阻止连接。

Try using a different tunneling service or test it on a device if you haven't yet.尝试使用不同的隧道服务,或者如果您还没有在设备上进行测试。

If none of the above solutions work, you might consider checking the log of server and React native App for more details, to see if there is any error message that can help you understand the problem.如果以上解决方案均无效,您可以考虑查看服务器和 React native App 的日志以获取更多详细信息,查看是否有任何错误消息可以帮助您了解问题。

It's also worth noting that some hosting providers may not support WebSocket connections over HTTPS, so it's worth checking with them if this is the case.还值得注意的是,一些托管服务提供商可能不支持 HTTPS 上的 WebSocket 连接,因此如果是这种情况,值得与他们核实。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM