我正在尝试通过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) 我的视频播放器有问题,现在我正在寻求帮助
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)
以前有人遇到过这个问题吗?:(