YAWS Websocket 问题
我正在尝试从 YAWS websocket 示例获取 YAWS websocket 示例.hyber.org/websockets_example.yaws" rel="nofollow">此处 在我的本地运行。它是一个基本的基于 ws 的 echo 服务器。
我已经
- 在
localhost:8080
上设置并运行了 YAWS(直接来自 Debian 存储库;除了将其指向新的根目录之外,没有任何配置更改) - 从 此页面包含在
标记中,另存为websockets_example_endpoint.yaws
- 此页面另存为
index.yaws< /code> (我确实复制/粘贴了它的视图源,将其保存为该文件并将套接字请求指向
localhost:8080
而不是yaws.hyber.org)。
当我在浏览器中访问 localhost:8080/websockets_example_endpoint.yaws 时,它会按预期显示文本“您不是 Web 套接字客户端!走开!”。当我访问 localhost:8080 时,它会将我指向启用 JavaScript 的表单,但单击“连接”按钮时不会执行任何操作。如果我将 index.yaws
指向 yaws.hyber.org
而不是 localhost:8080
,则 echo 服务器将完全按预期连接并工作。
谁能给我提示我做错了什么(或者指出我的工作示例来源)?
I'm trying to get the YAWS websocket example from here running on my local. It's a basic ws-based echo server.
I have
- YAWS set up and running on
localhost:8080
(direct from the Debian repos; no conf changes except pointing it to a new root directory) - the code listing from the bottom of this page wrapped in
<erl>
tags saved aswebsockets_example_endpoint.yaws
- this page saved as
index.yaws
(I literally copy/pasted the view-source for it, saved it as that file and pointed the socket request atlocalhost:8080
rather thanyaws.hyber.org
).
When I visit localhost:8080/websockets_example_endpoint.yaws
in-browser, it displays the text "You're not a web sockets client! Go away!", as expected. When I visit localhost:8080
, it points me to the javascript enabled form, but the "Connect" button does nothing when clicked. If I leave index.yaws
pointed at yaws.hyber.org
instead of localhost:8080
, the echo server connects and works exactly as expected.
Can anyone give me a hint as to what I'm doing wrong (or alternatively, point me to source for a working example)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我创建了一个 gitbub 项目:
https://github.com/f3r3nc/yaws-web-chat/
这是也是嵌入雅司病并通过群聊扩展的示例。
请注意,WebSocket 标准正在开发中,因此浏览器应该支持相同的 WS 版本才能正常工作。
雅司病 1.91 适用于 Safari 版本 5.1.1 (6534.51.22),但不适用于 Chrome (15.0.874.102),可能不适用于 (14.x)。
There is a gitbub project, I've created:
https://github.com/f3r3nc/yaws-web-chat/
This is also an example for embedding yaws and extended with group chat.
Note, that the standard of WebSocket is under development thus yaws and the browser should support the same WS version in order to work correctly.
yaws 1.91 works with Safari Version 5.1.1 (6534.51.22) but does not with Chrome (15.0.874.102) and probably not with (14.x).
对我来说,问题是我没有 basic_echo_callback 模块文件,因为我使用包存储库而不是构建表单源安装了 yaws。
如果在交互模式“yaws -i”下运行 yaws,则错误很明显:
这几乎是我在 Ubuntu 16.01 上从头开始的过程:
我的看起来像:
确保客户端中的端点正确:
停止服务器,如果已经运行并使用“yaws -i”启动服务器并浏览到:http://localhost:8000/websockets_example.yaws
它之所以有效,是因为每次服务器加载配置文件时,它都会编译指定 src 目录中的任何模块。如果缺少其他功能的其他模块,也需要下载它们。
For me the problem was I did not have the basic_echo_callback module file because I installed yaws using a package repository rather than building form source.
The error was evident if running yaws in interactive mode ´yaws -i´:
This is pretty much my process from scratch on Ubuntu 16.01:
Mine looks like:
Ensure endpoint is correct in the client:
Stop server if already running and start server with ´yaws -i´ and browse to: http://localhost:8000/websockets_example.yaws
It works because each time the server loads the configuration file it will compile any modules in the specified src directory. If other modules are missing for the other features they will also need to be downloaded.