Chromecast Receiver App错误:WebSocket意外断开连接:未定义 [英] Chromecast Receiver App Error: The WebSocket disconnected unexpectedly: undefined

查看:264
本文介绍了Chromecast Receiver App错误:WebSocket意外断开连接:未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取基本的chromecast应用设置,以便可以从Desktop Chrome向Chromecast接收器发送一条简单的自定义消息。设备被列入白名单,并且应用程序源位于白名单过程中指定的URL。另外,使用了正确的API_ID,并且接收方和发送方应用程序的名称空间相同。

I'm trying to get a basic chromecast app setup where I can send a simple custom message from Desktop Chrome to the Chromecast receiver. The devices is whitelisted, and the app sources are sitting at the url specified during the whitelisting process. Additionally the correct API_ID is being used and the NAMESPACE is the same for the receiver and sender apps.

接收方应用程序加载,但之后我得到:

The receiver app loads, but just after that I get:

[  0.230s] [goog.net.WebSocket] The WebSocket disconnected unexpectedly: undefined

这似乎使我无法向Chromecast发送自定义消息。

This seems to be preventing me from being able to send custom messages to the Chromecast.

发件人发送方应用程序,我能够找到该设备,连接并启动接收方应用程序。我也可以通过发送方上的stopActivity()调用来正确断开连接。

From the sender app I am able to locate the device, connect, and launch the receiver app. I am also able to properly disconnect with the stopActivity() call on the sender.

接收方的设置为:

var receiver = new cast.receiver.Receiver(APP_ID, NAMESPACE);
var channelHandler = new cast.receiver.ChannelHandler(NAMESPACE);

channelHandler.addChannelFactory(receiver.createChannelFactory(NAMESPACE));

channelHandler.addEventListener('error', function($e){
    console.log('JAC - Error!');
});

channelHandler.addEventListener('open', function($e){
    console.log('JAC - OnOpen!');
});

channelHandler.addEventListener('message', function($e){
    console.log('JAC - Message: ' + $e.type);
});


receiver.start();

Chromecast设备的完整日志为(实际appId已删除):

The full log from the Chromecast device is (actual appId removed):

[  0.027s] [cast.receiver.ChannelHandler] New channel factory added: MY-APP-ID to heartbeatChannelHandler
 cast_receiver.js:66
 [  0.088s] [cast.receiver.ChannelHandler] New channel factory added: receiverTest1: MY-APP-ID to receiverTest1
 cast_receiver.js:66
 [  0.094s] [cast.receiver.ConnectionService] Open connection service websocket: url=ws://localhost:8008/connection
 cast_receiver.js:66
 [  0.098s] [goog.net.WebSocket] Opening the WebSocket on ws://localhost:8008/connection
 cast_receiver.js:66
 [  0.104s] [cast.receiver.Receiver] Receiver started.
 cast_receiver.js:66
 [  0.142s] [goog.net.WebSocket] WebSocket opened on ws://localhost:8008/system/control
 cast_receiver.js:66
 [  0.153s] [cast.receiver.ChannelOverWebSocket] Dispatch OPEN event to ws://localhost:8008/system/control
 cast_receiver.js:66
 [  0.159s] [cast.receiver.Channel] Dispatch OPEN event to ws://localhost:8008/system/control
 cast_receiver.js:66
 [  0.164s] [cast.receiver.Platform] Platform channel is open: ws://localhost:8008/system/control
 cast_receiver.js:66
 [  0.208s] [goog.net.WebSocket] WebSocket opened on ws://localhost:8008/connection
 cast_receiver.js:66
 [  0.212s] [cast.receiver.ConnectionService] Got event: d
 cast_receiver.js:66
 [  0.222s] [goog.net.WebSocket] The WebSocket on ws://localhost:8008/connection closed.
 cast_receiver.js:66
 [  0.225s] [cast.receiver.ConnectionService] Got event: a
 cast_receiver.js:66
 [  0.230s] [goog.net.WebSocket] The WebSocket disconnected unexpectedly: undefined

对此事的任何帮助将不胜感激!谢谢!

Any help in the matter would be greatly appreciated! Thanks!

推荐答案

<$ c $中 NAMESPACE 的类型c> Receiver 构造函数必须是一个数组。我猜在您的代码示例中,它是一个字符串。这可能会导致您看到奇怪的问题。

The type for NAMESPACE in the Receiver constructor needs to be a an array. I'm guessing that in your code sample it is a string. That could cause the strange problems you are seeing.

这篇关于Chromecast Receiver App错误:WebSocket意外断开连接:未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆