dsbowmvth16379079 2016-11-08 04:11
浏览 201

如何从用Go编写的客户端连接到sockJS?

I have a server that uses websockets. It is written in Go. For testing, I have another application written in Go. To test, I start the server, then run the test client. The test client creates websocket connections to the server and does things (basically impersonating user activity). Both the client and the server are using the gorilla/websockets library, and standard browsers also work fine with the server.

This was all working beautifully.

To support non-compliant browsers, I was asked to start using the SockJS Go server library. I did this and the new version works just fine when used from a browser by clients using the SockJS library.

Now for the problem. SockJS does not accept incoming websocket connections. Only connections from the SockJS client. So my testing application doesn't work, and I'm unable to test.

I could recover the old version of my connection code from git and make a separate connection type that uses gorilla/websockets and have my server listen on an additional port that only listens on localhost. This would allow me to test the functionality. The downside is that I have to maintain two versions of essentially the same code, and I wouldn't be testing the real user experience and possibly not find bugs until production.

Ideally the SockJS server, considering it still uses gorilla/websockets as a dependency would automatically accept proper websocket connections, but barring that it seems I'd need a SockJS client library in Go which, as far as I can tell, doesn't exist.

Does anyone have a solution for this? Thanks!

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流
    • ¥15 Rstudio 保存代码闪退
    • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
    • ¥50 invest生境质量模块