问题描述
我的应用程序在浏览器上正常工作。
当我用intelXDL / phonegap编译时:AJAX调用正常,但不是socket.io连接。 (套接字使用端口1445)
我有
,因此看起来像权限问题
我试图为白名单添加所有可能的组合(我使用CLI 4.1.2)
http://www.example.com/*
http://www.example.com:1445/*
http:// *:1445 / *
http:// *
*
第一个规则使AJAX调用可能。其他规则不允许连接到端口1445上的socket.io
任何想法?
@yarek,
这是一个明确的答案,因为Cordova只是移动文档,没有警告或公告。
修复许多常见的白名单问题
另一种方法是快速修复–但请注意,此快速修复会删除白名单
的所有需求。这会创建您不希望传递的。 p>
QUICK FIX 将 config.xml
添加到 PHONEGAP BUILD ONLY
< preference name =phonegap-versionvalue =3.7.0/>
长的答案是这样的:
从:
- #6 不为您的编译器设置phonegap版本
- #7
- #10 不会在config.xml中添加新的白名单和白名单插件参数。 / li>
对于#6& #7
对于#10
相关链接
My application works fine on browser.
When I compile it with intelXDL / phonegap : AJAX calls works fine, but not socket.io connections. (sockets use port 1445)
I have
so it looks like permissions problem
I tried to add ALL possible combinations for whitelist (I use CLI 4.1.2)
http://www.example.com/*
http://www.example.com:1445/*
http://*:1445/*
http://*
*
The first rule makes AJAX call possible. The other rules do not allow to connect to socket.io on port 1445
Any idea ?
@yarek,
This is a canned answer because Cordova just move the documentation, without warning or announcement.
The fix to many common white-list problems
The alternative is this quick fix – but know that this quick fix removes all needs for white-list
. This creates a security issue which you may not want to by pass.
QUICK FIX Add this to your config.xml
for PHONEGAP BUILD ONLY<preference name="phonegap-version" value="3.7.0" />
The long answer is as such:
From Top Mistakes by Developers new to Cordova/Phonegap you have hit:
- #6 Not setting the "phonegap version" for your compiler
- #7 Not setting "version" for you plugins
- #10 Not adding the new "white-list" and "white-list plugin" parameters in config.xml.
For #6 & #7
For #10
Related Links
这篇关于cordova / phonegap:无法连接到socket.io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!