首页 > 解决方案 > SSE 无法通过使用域名在 android 中运行

问题描述

我正在使用来自 Ajax “<a href="https://username%40gmail.com:password@home.myopenhab.org/rest/events?topics=smarthome/" rel="nofollow noreferrer">https:// /username%40gmail.com:password@home.myopenhab.org/rest/events?topics=smarthome/" 使用 Cordova 在客户端应用程序中获取 SSE。它在 IOS 上工作正常,但在 android 上不工作。对于相同的 URL,如果我给像“ http://192.168.0.1/rest/events?topics=smarthome/ ”这样的IP,它在IOS和android上都可以正常工作。

我的代码是这样的

var eventSource = new EventSource(" +“url”+ /rest/events?topics=smarthome/*");   


eventSource.addEventListener(‘message’, function (eventPayload)
{
//not entering here.
}

标签: cordovaopenhab

解决方案


推荐阅读