PhoneGap的WebSocket的插件与Android版本> 4.0.3不工作 [英] Phonegap websocket plugin with android version >4.0.3 not working

查看:458
本文介绍了PhoneGap的WebSocket的插件与Android版本> 4.0.3不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在执行与的PhoneGap ,使用HTML5和JavaScript跨plattform的移动应用程序。我决定使用的WebSockets 以建立通信和交换数据,我们的后端服务器的连接。的WebSockets被黑莓和iOS浏览器的默认支持。对于安卓也有一些有前途的插件集成的WebSockets到的Andr​​oid的Java code和使用Javascript在PhoneGap的执行。 我选择了这一个:

I'm currently implementing a cross-plattform mobile app with Phonegap, using HTML5 and Javascript. I decided to use Websockets to establish a connection to our backend server for communication and exchanging data. Websockets are supported by Blackberry and iOs browsers by default. For Android there are some promising plugins to integrate websockets into Android java code and execute it in Phonegap using Javascript. I chose this one:

WebSocket的,Android的PhoneGap的

websocket-android-phonegap

我整合了插件安装到我的Andr​​oid项目,并遵循自述每一步。然后,我与Android 4.0.3测试了物理设备的三星Galaxy Nexus的。它的工作很好,在那里有没有明显的差异,黑莓和iOS的使用。我还部署应用程序到三星Galaxy Tab 2

I integrated that plugin into my android project and followed every step in the readme. Then I tested it on physical device Samsung Galaxy Nexus with Android 4.0.3. It worked fine and there where no visible differences to Blackberry and iOs usage. I also deployed the app to a Samsung Galaxy Tab 2

嗯,如果我部署的应用程序与操作系统版本高于4.0.3的Andr​​oid设备(testet在4.1.2和4.2.2)出现我的问题。它如果我使用的是三星Galaxy Nexus的采用Android 4.2.2即使出现了问题!

Well, my problem occurs if I deploy the app to an Android device with os version higher than 4.0.3 (testet on 4.1.2 and 4.2.2). It even appears a problem if I use a Samsung Galaxy Nexus with Android 4.2.2!

多汁的事情是,我使用PhoneGap的2.6.0它自动创建它是基于操作系统版本4.2.2 !!

The juicy thing is, that I use Phonegap 2.6.0 which automatically creates Android project which is based on OS version 4.2.2!!

现在的问题是,该项目的原生Android的部分内的WebSocket服务器无法打开连接到请求的客户端。通常情况下,客户端发送请求,要求打开经由该连接已经建立回调连接和服务器通知客户端。

The Problem is, that the Websocket server inside the native Android part of the project cannot open the connection to the requesting client. Normally the client sends a request to open connection and the server notify the client via callback that the connection has been established.

如果Android的4.0.4+使用的服务器连接返回404错误请求消息,而不是打开的连接。

由于这个问题我尝试了一些其他插件,其实每一个我可以找到。在Android 4.0.3,没有更高版本他们都工作得很好。

Due to that issue I tried some other plugins, in fact every single one I could found. All of them worked fine on Android 4.0.3, none on higher versions.

尝试WebSocket的-插件2

尝试WebSocket的-插件3

尝试WebSocket的-插件4

尝试WebSocket的-插件5

有没有人在那个特定主题的任何经验,可以给我一个提示,我可能忘了,或指向我必须考虑?我无法想象,没有工作的WebSocket插件的Andr​​oid 4.0.4+都可以!

Has anyone any experience in that specific topic and can give me a hint, what I possibly forgot or which points i have to consider? I cannot imagine that no working websocket plugin for Android 4.0.4+ are available!

推荐答案

有可能是2个问题在这里:库未更新太久,只实现一个过时版本的WebSocket协议。其次,近期的Andr​​oid版本不允许的任意的主/ UI线程上的网络活动。

There might be 2 issues here: the library wasn't updated for long and only implements an outdated version of the WebSocket protocol. Second, recent Android versions don't allow any networking activity on the main/UI thread.

AutobahnAndroid 实现RFC6455的WebSocket和执行的所有的网络活动的后台线程。没有与PhoneGap的任何集成,但。

AutobahnAndroid implements RFC6455 WebSocket and performs all network activity on background threads. There isn't any integration with Phonegap though.

免责声明:我是高速公路的原作者和工作Tavendo

Disclaimer: I am original author of Autobahn and work for Tavendo.

这篇关于PhoneGap的WebSocket的插件与Android版本> 4.0.3不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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