是否可以使用https的WebSockets?切换到https时,我的WebSocket会返回一个安全错误,并且可以与常规http完美配合...
socket = new WebSocket("ws://my_www:1235");
Run Code Online (Sandbox Code Playgroud)
谢谢
如何重新连接socket io一次disconnect
被调用?
这是代码
function initSocket(__bool){
if(__bool == true){
socket = io.connect('http://xxx.xxx.xxx.xxx:8081', {secure:false});
socket.on('connect', function(){console.log('connected')});
socket.on('disconnect', function (){console.log('disconnected')});
}else{
socket.disconnect();
socket = null;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我这样做initSocket(true)
,它的确有效.如果我这样做initSocket(false)
,它会断开连接.但是,如果我尝试重新连接使用initSocket(true)
,则连接不再起作用.如何才能使连接正常工作?
我正在运行Node 0.6.16并且所有模块都是最新的,至少根据npm(win7 x64).我注意到,即使我没有断线,但由于某种原因,过了一段时间,我不知道,也许1小时,浏览器没有收到任何数据.它似乎在FF上比在Chrome上更频繁.
socket.on('disconnect', function (){console.log('disconnected')});
Run Code Online (Sandbox Code Playgroud)
这永远不会触发该特定事件(我的意思是它可能会发生,但后来我得到了日志和socket.io自动重新连接 - 在这种情况下,没有任何反应,它只是停止工作,这是最常见的事件).
所以我不知道在哪里看.NodeJS仍然记录心跳,但由于某种原因,连接没有通过.我怀疑,在(任何?)浏览器的标签更改,一段时间后,由于窗口/标签不再有焦点,socket.io停止接收数据?我可能错了,它可能与焦点无关,但这是我的主要领导.其他人有什么想法吗?
编辑:客户端很简单:
socket = io.connect('http://xxx.xxx.xxx.xxx:8081', {secure:false, 'reconnect': true, 'reconnection delay': 500, 'max reconnection attempts': 10});
socket.on('connect', function(){console.log('connected')});
socket.on('message', function(data){//do something);
socket.on('disconnect', function (){console.log('disconnected')});
Run Code Online (Sandbox Code Playgroud)
Edit2:更新到最新版本的socket.io(1.2.1)和节点v0.10.35后,我仍然遇到同样的问题.更令人惊讶的是,我在客户端添加了以下代码:
function checkSocket(){
if(socket){
if(!socket.connected){
console.log('socket disconnected');
clearInterval(intv);
}
}
}
intv = setInterval(checkSocket, 1000);
Run Code Online (Sandbox Code Playgroud)
虽然该函数每秒运行一次,但它永远不会记录套接字断开连接,即使它不再接收任何内容并仍然发送心跳.
Edit3:好吧,它在我的服务器端代码,一些套接字被破坏.还更新到v1.x并强制重新连接.
我正在寻找一种简单的方法来将Apache 2.4.x中的IP地址列入黑名单.我的网站将尝试非法操作的IP地址记录到文本文件中.我想在Apache中使用这个文本文件来拒绝所有访问此ip列表的所有vhosts.什么是最好的方式(最容易和最少资源消耗的方式)?发现这个,但这仅适用于2.2 ..不确定这是如何适用于2.4 ..干杯.
编辑:这是一个运行apache x64的windows x64盒子
我使用插件cordova-plugin-geolocation.我唯一的问题是允许位置的消息提示如下所示:
/var/container/bundle/application/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/my_project/www/index.html想要使用您的位置.
反正有没有更性感的东西,比如说
my_project想要使用你的位置
干杯.
为非信徒添加了一些代码
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
navigator.geolocation.getCurrentPosition(onLocationSuccess, onLocationError, {maximumAge:3000, timeout:2000, enableHighAccuracy:true});
function onLocationSuccess(){
}
function onLocationError(){
}
}
Run Code Online (Sandbox Code Playgroud) 我在这里读了几个关于这个问题的问题,但是找不到我想要的答案.我正在使用jQuery向PHP5.6服务器做一些$ .post.
$.post('/', {a:100, b:'test'}, function(data){
}, 'json');
Run Code Online (Sandbox Code Playgroud)
控制台的编码是
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用常规$ _POST读取POST数据,PHP5.6会提醒我
PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead
Run Code Online (Sandbox Code Playgroud)
那么我已经尝试了这个建议,在php.ini中添加了always_populate_raw_post_data = -1并且
json_decode(file_get_contents("php://input"));
Run Code Online (Sandbox Code Playgroud)
PHP5.6警告我它无效
PHP Warning: First parameter must either be an object or the name of an existing class
Run Code Online (Sandbox Code Playgroud)
所以我转储了file_get_contents("php:// input")并且它是一个字符串.
a=100&b="test"
Run Code Online (Sandbox Code Playgroud)
所以我解析了字符串并编码然后解码
parse_str(file_get_contents("php://input"), $data);
$data = json_decode(json_encode($data));
var_dump($data);
Run Code Online (Sandbox Code Playgroud)
然后我终于将我的$ data作为对象而不是数组,作为一个真正的JSON对象.
我现在暂时继续使用$ _POST …
我正在使用php与SOAP中的web服务进行通信.这是我的代码:
$data = array('name' => 'test', 'age' => 20);
$WDSL = 'http://xxx.xxxxx.xxx/wdsl.ibs?wsdl';
$SOAP = new SoapClient($WDSL, array('trace' => true));
$RESULT = $SOAP->__soapCall('Some_Service', $data);
Run Code Online (Sandbox Code Playgroud)
出于某种原因,XML是错误的:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Some_Crap"><SOAP-ENV:Body><ns1:Some_Service/><param1>test</param1><param2>20</param2> ...
Run Code Online (Sandbox Code Playgroud)
当XML节点名称应该是变量名时,它是如何变换的?我究竟做错了什么 ??
谢谢
更新:所以我列出了该Web服务的功能,我得到的是:
Some_Service_Response Some_Service(Some_Service $parameters))
Run Code Online (Sandbox Code Playgroud)
我改变了我的电话,现在是:
$SOAP->__call('Some_Service', array('Some_Service', $data));
Run Code Online (Sandbox Code Playgroud)
XML仍然是错误的:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:iwaysoftware:ibse:jul2003:HR_Master"><SOAP-ENV:Body><ns1:Some_Service/>
<param1><item><key>SomeKey</key><value>SomeValue</value> ....
Run Code Online (Sandbox Code Playgroud)
我还是得到的 <param1><item><key>SomeKey</key><value>SomeValue</value> instead of
<Somekey>SomeValue</Somekey>
所以问题是,Web服务不能正常运行还是我的结束?
自从Cordova v8的最新更新以来,我无法在Mac上构建任何东西.我总是得到
(node 626) UnhandledPromiseRejectionWarning: Error: Cannot find module '../cordova/platform_metadata'
Run Code Online (Sandbox Code Playgroud)
我尝试了这篇文章中的建议,但我得到了同样的错误.
然后我做了一个详细的,看起来为ios构建所需的插件效果不佳
Executing script found in plugin cordova-plugin-swift-support for hook "after_prepare": plugins/cordova-plugin-swift-support/src/add-swift-support.js
Resolving module name for cordova-lib/src/cordova/platform_metadata => ../cordova/platform_metadata
(node:599) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): Error: Cannot find module '../cordova/platform_metadata'
(node:599) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.
Run Code Online (Sandbox Code Playgroud) 我认为Ionic在iOS中有一个巨大的错误。我收到以下错误消息:
2019-11-06 12:09:31.560205+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.560562+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.660322+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.660699+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.765716+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.767176+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.862421+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.863232+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:33.680251+0100 MyApp[6687:1400464] [Process] kill() returned unexpected …
Run Code Online (Sandbox Code Playgroud) 我使用这个库:Oauth2 PHP
我找不到更改过期时间的设置,我尝试过:
new OAuth2\Server($this->_mem, array('use_jwt_access_tokens' => true, 'access_token_lifetime' => 2419200));
Run Code Online (Sandbox Code Playgroud)
但令牌的生命周期始终为 3600。正确的设置是什么?
编辑:按照建议,我尝试使用刷新令牌
new OAuth2\Server($this->_mem, array('use_jwt_access_tokens' => true, 'always_issue_new_refresh_token' => true));
Run Code Online (Sandbox Code Playgroud)
client_credential 授予类型 + JWT 承载有效,但我从未获得刷新令牌(仅访问令牌)。即使经过令牌验证,我也从未获得刷新令牌。
编辑:由于刷新对我不起作用,正如建议的那样,我尝试设置令牌过期时间
new OAuth2\Server($this->_mem, array('use_jwt_access_tokens' => true, 'access_lifetime' => 12000));
Run Code Online (Sandbox Code Playgroud)
对客户端凭据的响应仍然返回一个短令牌
{ ["access_token"]=> string(648) "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpZCI6ImU0NjE0MzdhMjY2YjFkNWY0OWU5MDY5MjQwODg5NjU0MDI2ZGRmODAiLCJpc3MiOiIiLCJhdWQiOiI4OWM2MjRmNTNiYTVmOTM3NjFmZWFhNmU1MGI1ZDk1NGQ4ZGRjMTIxIiwic3ViIjpudWxsLCJleHAiOjE0MzQ0NjI2NDIsImlhdCI6MTQzNDQ1OTA0MiwidG9rZW5fdHlwZSI6ImJlYXJlciIsInNjb3BlIjoicHVibGljIHJlYWRfbmV3cyJ9.Mk_KyUk_8yPnq9eEjvgVOJXBOkQSifAPbEaUvY4X9WvfmImPnC7PJx_99ODpiJR_gMLhZ3gBl1gQEJ2z6xUZ83dntCYzGWumkVLNpJG8omuVkmZqNnbLYYXl-vzmGOblceeDrKw_lrXc4rb72BeFaMeZWwFV7YMrgA0LOsYyZmAiDblcbHtpPGpUd2EC3y7VxLnyA8u07eY4aswOHwClPlDwHX_HwfMUmDLWkoTcrRf1AvKn-cnj41eL0SU9AJHWab8AOK7lxDsaqnits5pXj--cG9hr8pWOsFPQ2D9qYOsMvbEOi4zDJEdaIp-qvzn6N5Wrm5GxdbU1AqwvM531hQ" ["expires_in"]=> int(3600) ["token_type"]=> string(6) "bearer" ["scope"]=> string(16) "public" }
Run Code Online (Sandbox Code Playgroud)
看来这是一个缓存问题,令牌现在设置为正确的过期长度/时间