小编Con*_*ter的帖子

使用cowboy和MessagePack在websocket上发送二进制数据

我正在尝试通过WebSocket将来自Cowboy的MessagePack编码消息发送到浏览器,并且接收的数据始终为空或无效.我能够将JS中的二进制数据发送给我的牛仔处理程序,但反之亦然.我正在使用Cowboy 1.0.4和官方msgpack-erlang应用程序.我也msgpack-lite用于我的浏览器中的JavaScript.

例子:

websocket_handler:

websocket_handle({text, <<"return encoded">>}, Req, State) ->
    %% sends encoded message to client. Client is unable to decode and fails
    {reply, {binary, msgpack:pack(<<"message">>)}, Req, State};
websocket_handle({binary, Encoded}, Req, State) ->
    %% Works as expected
    lager:info("Received encoded message: ~p", [msgpack:unpack(Encoded)]),
    {ok, Req, State};
Run Code Online (Sandbox Code Playgroud)

JS:

var host = "ws://" + window.location.host + "/websocket";
window.socket = new WebSocket(host);
socket.binaryType = 'arraybuffer';
socket.onmessage = function(event) {
    var message = msgpack.decode(event.data);
    console.log(message);
};
Run Code Online (Sandbox Code Playgroud)

浏览器在msgpack.min.js中返回错误:

Error: Invalid type: …
Run Code Online (Sandbox Code Playgroud)

javascript erlang websocket messagepack cowboy

7
推荐指数
1
解决办法
1609
查看次数

video.js IE 9 mp4/webm错误

我的视频播放器有问题,现在我正在寻求帮助

Video.js无法在IE 9中播放视频(可能是10,我无法检查),所有其他浏览器都能正确显示视频

这是一个示例链接.

IE控制台显示以下错误:

日志:视频错误[对象对象]

HTML代码:

<video class='video-js vjs-default-skin' controls data-setup='{"techOrder": ["flash", "html5", "links"]}' height='576' id='video_16' poster='/system/videos/file_previews/000/000/016/medium/1360091100-30.jpg?1360091101' preload='none' width='720'>
    <source src='http://uklasi.com.ua/5-klas/matematika/koordinatniy-promin/16.mp4' type='video/mp4'>
    <source src='http://uklasi.com.ua/5-klas/matematika/koordinatniy-promin/16.webm' type='video/webm'>
</video>
Run Code Online (Sandbox Code Playgroud)

我的HTTP标头:

HTTP/1.1 200 OK
Server: nginx/1.2.6
Date: Sun, 10 Feb 2013 12:05:40 GMT
Content-Type: video/mp4
Content-Length: 41625464
Last-Modified: Tue, 05 Feb 2013 19:05:00 GMT
Connection: keep-alive
Content-Disposition: inline; filename="koordinatniy-promin-16"
Cache-Control: max-age=0, private, must-revalidate
Accept-Ranges: bytes
Run Code Online (Sandbox Code Playgroud)

以前有人遇到过这个问题吗?:(

video.js

3
推荐指数
1
解决办法
5177
查看次数

标签 统计

cowboy ×1

erlang ×1

javascript ×1

messagepack ×1

video.js ×1

websocket ×1