octane
octane copied to clipboard
Connection refused error when streaming OpenAI responses
Octane Version
2.3.0
Laravel Version
10.41.0
PHP Version
8.3.1
What server type are you using?
FrankenPHP
Server Version
FrankenPHP 1.0.3 | Caddy v2.7.6
Database Driver & Version
N/A
Description
Ran into an issue streaming responses with the openai-php/client package. Calling the createStreamed method in a FrankenPHP Octane environment throws a connection refused error.
I've isolated it to an Octane FrankenPHP issue since streaming works fine using FrankenPHP alone. It also seems to work fine using Octane Swoole.
Steps To Reproduce
I created a minimal reproduction of the issue here: https://github.com/benbjurstrom/octane-streaming-bug-report.
Had a chance to look at this again and confirmed it's not an issue with the openai-php package. Instead this error occurs anytime you pass the stream => true
flag to guzzle in a FrankenPHP Octane environment.
// use GuzzleHttp\Client;
$client = new Client();
$response = $client->get('https://api.openai.com/v1/chat/completions', [
'stream' => true
]);
@dunglas is it okay if I assign these FrankenPHP issues to you?
@driesvints Sure
@dunglas Any update on this? We're having this issue too. We'd like to use streaming responses for our AI features and recently moved to FrankenPHP.
I wonder if it's not the same issue as https://github.com/dunglas/frankenphp/issues/582?
@dunglas Not sure but we're having another issue related to streaming that might be related. Streaming an excel file downloads an empty file. It works correctly with valet, but breaks when using frankenphp. Switching to download instead of using a stream fixes the issue.
Would you be able to provide a simple/small reproducer?
This is being fixed by https://github.com/dunglas/frankenphp/pull/692.
Thanks @dunglas. Gonna close this already if it's a Frankenphp thing.