Comments (3)
The connection
property of the $req
will be deleted after the send()
call.
So you can store connection
to a variable. Codes like this.
$connection = $req->connection;
$connection->send( (new Response(200, ...);
$callback = function ($row) use ($connection) {
$connection->send( new Chunk( implode(',', (array) $row) ) );
};
from workerman.
Great, changing as you suggest it works that part. But I'm facing this, once the process sending chunk's has finished, I doing this:
$callback = function ($row) use ($connection) {
$connection->send( new Chunk( implode(',', (array) $row) ) );
};
$result = $bo->{$report}(QueryRequest::getInstance($req), $callback);
return (new Response(200))->withBody( new Chunk('') );
But, the browser is detecting a failed and abort the download, as you can see in this image:
the return line could be the problem?, I'm doing this, because I need to return a Response
object beacuse it's on middleware flow, and the last middleware expect to get a Response
object to send the last result
Any suggestion? Thanks
from workerman.
Well, I solved it, just changed like this:
$callback = function ($row) use ($connection) {
$connection->send( new Chunk( implode(',', (array) $row)."\n" ) );
};
$result = $bo->{$report}(QueryRequest::getInstance($req), $callback);
$connection->send( new Chunk('') );
return new Response(200);
Thanks anyway! Workerman
it's a great framework.
from workerman.
Related Issues (20)
- Run Workerman in daemon mode with Windows HOT 2
- Estrange behavior in composer require HOT 1
- runtime test HOT 2
- add a watch command
- ssl secure connection HOT 1
- Transferring data between workers HOT 5
- What different between Protocols\Ws vs Protocols\Websocket ? HOT 2
- TCP connection->send always returns null HOT 1
- $request->path() 有问题 HOT 1
- Output a grouped routing list HOT 1
- How to deploy in Azure App Service HOT 1
- 代理模式无法使用。出现报错 Send of xxx bytes failed with errno=57 Socket is not connected
- workman没有正确设置sapi_globals_struct的request_info HOT 3
- worker数量与多核心问题 HOT 19
- Is possible to build workerman as a PHP extension such as use zephir
- Multiple connection to one user? HOT 1
- PHP8.4弃用了隐式可空类型 HOT 1
- permessage-deflate support problem HOT 3
- webman 第一次响应都很慢 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workerman.