hprose / hprose-swoole Goto Github PK
View Code? Open in Web Editor NEWHprose asynchronous client & standalone server based on swoole
License: MIT License
Hprose asynchronous client & standalone server based on swoole
License: MIT License
"require": {
"php": ">=5.3.0",
"hprose/hprose": ">=2.0.9",
"ext-swoole": ">=1.8.8"
},
应为 "hprose/hprose-php":">=2.0.9"
hprose-swoole does not support swoole 4.4, even async is installed, Undefined property still exists.
PHP Notice: Undefined property: Swoole\Http\Client::$id in /var/www/html/enclog /vendor/hprose/hprose-swoole/src/Hprose/Swoole/Http/Transporter.php on line 142
用的是README里面的代码,执行 tcp_cliet.php 报warning:
Warning: swoole_timer_clear(): timer#11 is not found. in src/Hprose/Swoole/Socket/Transporter.php on line 42
PHP 版本: 7.2.2
Swoole 版本:2.1.0
客户端:使用hprose-ruby,ruby:2.5.0,rails:5.1.5
服务端:使用hprose/swoole/server, php: 7.1.16, laravel: 5.5
实际使用过程中,客户端调用服务时,参数总体长度超过124时服务端疑似卡在
$self->defaultHandle($data, $context)->then(function($data) use ($self, $server, $socket, $id) { $self->socketSend($server, $socket, $data, $id); });
现在用的异步已经被swoole新版本砍掉,作为独立扩展了。使用swoole推荐用协程,是否实现一下协程版本。其实主要是websocket、http版本需要swoole的。socket版本可以使用swoole一键协程化来做支持。
有什么办法解决此问题?
hprose-swoole 2.0.7
搭建服务,用户使用iphone 6s QQ浏览器访问服务发布的接口时,接口会停止服务,其它任何方式的访问接口都无返回值,重启服务后恢复正常。hprose 1.5.6
版本。bug出现环境:
{
"host":"192.168.2.67:8003",
"origin":"http://192.168.2.102:8080",
"accept-encoding":"gzip, deflate",
"connection":"keep-alive",
"accept":"*/*",
"user-agent":"Mozilla/5.0 (iPhone 6sp; CPU iPhone OS 10_1_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 MQQBrowser/7.2 Mobile/14B100 Safari/8536.25 MttCustomUA/2 QBWebViewType/1",
"content-length":"0",
"referer":"http://192.168.2.102:8080/hprose-web/index.html?_ijt=g21st5f9d04he2p1dd96tbhgoh",
"accept-language":"zh-cn"
}
hprose-swoole
库的不同版本hprose
库的不同版本hprose
和 http
hprose-swoole
在2.0.7与2.0.11两个版本中,使用apple 6s qq浏览器
通过hprose
访问,将出现这个问题。其中2.0.11
为最新版本。hprose
版本为1.5.6
时,任意浏览器或访问方式均访问正常。1.5.6
为 1.*.*
最后一个版本。其中1.*.*
自带swoole服务的创建,而到了2.*.*
时,不带swoole服务的创建,已经转向了hprose-swoole
库中。arc
工具模拟异常包的头信息发送,bug未重现。红米note3上的qq浏览器
,使用hprose
访问接口,bug未出现。apple 6s qq浏览器
通过http
访问接口,无bug出现。unset
掉 content-length
头信息,无效果。hprose-swoole-2.0.11
代码web端代码
代码apple 6s qq浏览器
访问web端页面,此时bug重现。hprose-swoole
库中的一个bug。iphone 6s qq浏览器
通过hprose
方式访问hprose-swoole
的服务时,会出现此bug。content-length: 0
,故临时解决办法,在服务器获取到content-length: 0
的包时,不做处理直接return。hprose-swoole
的git issues中,等待bug确认并修复。hprose-swoole
库更换为1.5.6
版本的hprose
库<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试</title>
<script type="text/javascript" src="hprose/hprose-html5.src.js"></script>
<script src="//cdn.jsdelivr.net/eruda/1.0.5/eruda.min.js"></script>
<script>eruda.init();</script>
</head>
<body>
<div id="retData"></div>
<script type="text/javascript">
var retData = document.getElementById('retData')
var url = 'http://192.168.2.67:8089' // 服务地址
var client = hprose.Client.create(url)
// 访问服务
client.invoke('hello', [], function (data) {
console.info('success', data)
retData.textContent = data
},function (error) {
console.info('error', error)
retData.textContent = error
})
</script>
</body>
</html>
{
"require": {
"hprose/hprose-swoole": "2.0.11"
}
}
<?php
require_once "./vendor/autoload.php";
use Hprose\Swoole\Server;
function hello($name) {
return "Hello $name!";
}
$url = "http://0.0.0.0:8089";
echo "url is $url" . PHP_EOL;
$server = new Server($url);
$server->addFunction('hello');
$server->start();
{
"require": {
"hprose/hprose-swoole": "2.0.7"
}
}
<?php
require_once "./vendor/autoload.php";
use Hprose\Swoole\Server;
function hello($name) {
return "Hello $name!";
}
$url = "http://0.0.0.0:8086";
echo "url is $url" . PHP_EOL;
$server = new Server("http://0.0.0.0:8086");
$server->addFunction('hello');
$server->start();
{
"require": {
"hprose/hprose": "1.5.6"
}
}
<?php
require_once "./vendor/autoload.php";
use Hprose\Swoole\Server;
function hello($name) {
return 'Hello ' . $name;
}
$url = "http://0.0.0.0:8087";
echo "url is $url" . PHP_EOL;
$server = new Hprose\Swoole\Server($url);
$server->addFunction('hello');
$server->start();
当worker进程意外挂掉后,之前的连接并未中断,新的worker进程重启后重新接管之前的socket连接,此时连接的上下文信息全部丢失,并且不会再次触发onConnect,只会触发onReceive事件, onReceives数组此时必然为空,导致如下异常:
PHP Notice: Undefined offset: 5 in /home/test/git/server/vendor/hprose/hprose-swoole/src/Hprose/Swoole/Socket/Service.php on line 150
PHP Fatal error: Function name must be a string in /home/test/git/server/vendor/hprose/hprose-swoole/src/Hprose/Swoole/Socket/Service.php on line 151
[2016-12-15 11:26:17 *95097.0] ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Function name must be a string in /home/test/git/server/vendor/hprose/hprose-swoole/src/Hprose/Swoole/Socket/Service.php on line 151.
composer.json
{
"require": {
"hprose/hprose-swoole": "dev-master"
}
}
index.php
<?php
require_once 'vendor/autoload.php';
use Hprose\Swoole\Http\Server;
function hello($name)
{
return "Hello $name!";
}
$server = new Server('http://0.0.0.0:8000');
$server->add('hello');
$server->debug
php index.php get error as blow:
php index.php
PHP Warning: require(/media/sf_php/test/hprose_demo/vendor/composer/../hprose/hprose/src/Hprose.php): failed to open stream: No such file or directory in /media/sf_php/test/hprose_demo/vendor/composer/autoload_real.php on line 66
PHP Fatal error: require(): Failed opening required '/media/sf_php/test/hprose_demo/vendor/composer/../hprose/hprose/src/Hprose.php' (include_path='.:/usr/share/php') in /media/sf_php/test/hprose_demo/vendor/composer/autoload_real.php on line 66
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.