Websockets on elixir code

天涯浪子 提交于 2019-12-11 08:49:46

问题


I'm currently creating a chat using elixir. but anytime i try running the app, the websocket gives an error on sever console

The client's requested channel transport version "2.0.0" does not match server's version requirements of "~> 1.0"

And browser console:

WebSocket connection to 'ws://localhost:4000/socket/websocket token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJVc2VyOjMiLCJleHAiOjE1MDQ0OTE1NTQsImlhdCI6MTUwMTg5OTU1NCwiaXNzIjoiU2xpbmciLCJqdGkiOiIyNWY5NDZkNy1jNDg5LTRiYWMtYjJkNS0zZDA4OTdkNDU1ZWMiLCJuYmYiOjE1MDE4OTk1NTMsInBlbSI6e30sInN1YiI6IlVzZXI6MyIsInR5cCI6ImFjY2VzcyJ9.nh-DaQfY8OuI0EBE7lILFx6hjm6J_ZrynXHeOLr1-wM-fXnDakqrZUSN1XFQnr0x0KM9WFOkLEQnip5DcsKxXw&vsn=2.0.0' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

回答1:


your phoenix javascript library (dependency) is updated without notice. You should fix version so it is limited to less than 1.3.0 in package.json (if you are using npm) or bower.json if you are using bower to use old implementation, or use narrowtux solution if you downloaded js file manually. Or upgrade phoenix version.




回答2:


With Phoenix 1.3, a new version of the transport protocol was released. It seems that you've somehow included the new version of the javascript client in your project, but are still running on Phoenix 1.2.

As a workaround, you can copy and reference the old client script here: https://github.com/phoenixframework/phoenix/blob/v1.2/web/static/js/phoenix.js



来源:https://stackoverflow.com/questions/45517636/websockets-on-elixir-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!