sergix44 / gradio-client-php

Gradio API client for PHP
MIT License
14 stars 2 forks source link

[Bug]: PHP Fatal error: Server sent invalid upgrade response: HTTP/1.1 403 Forbidden #8

Open AngelTs opened 12 months ago

AngelTs commented 12 months ago

What happened?

PHP Fatal error: Uncaught WebSocket\ConnectionException: Connection to 'wss://9797a8c499d50575a3.gradio.live/queue/join' failed: Server sent invalid upgrade response: HTTP/1.1 403 Forbidden

How to reproduce the bug

<?php
require __DIR__ . '/vendor/autoload.php';
use SergiX44\Gradio\Client;
$client = new Client('https://aefe63bef807636ece.gradio.live/');
$result = $client->predict(["Hello!!"], apiName: '/predict');
echo $result;
?>

I have one prompt for text (as input) and expected to generate one picture (as output)

Use via Python client API:

from gradio_client import Client
client = Client("https://aefe63bef807636ece.gradio.live/")
result = client.predict(
        "Hello!!",  # str  in 'prompt' Textbox component
                            api_name="/predict"
)
print(result)

Use via Javascript client API:

import { client } from "@gradio/client";
const app = await client("https://aefe63bef807636ece.gradio.live/");
const result = await app.predict("/predict", [      
                "Hello!!", // string  in 'prompt' Textbox component
    ]);
console.log(result.data);

Package Version

2.0.0

PHP Version

8.2.0

Which operating systems does with happen with?

Linux

Notes

No response

AngelTs commented 11 months ago

The strange thing is if use "Hello world" common well space, the PHP API works fine and correct, but if use the same php api in my server, the f..g error occures: HTTP/1.1 403 Forbidden

AngelTs commented 11 months ago

After one day of unsuccessful tests, maybe i found the reason for the error "wss:...Server sent invalid upgrade response: HTTP/1.1 403 Forbidden" with probability of 70-80% to be true: This API do not work with servers like "https://XXXXXXXXXXXXXXXXXX.gradio.live/" and "https://XXXXXXXXXXXXXXXXXX.gradio.live/queue/join". Only works with HF spaces servers like "https://XXXXXXX.hf.space/api/predict", "https://XXXXXXX.hf.space", "https://huggingface.co/spaces/XXXXXXXXX", etc.

AngelTs commented 11 months ago

Twice confirmed that this library do NOT works with "https://xxxxxxxxxxxxxxxxxx.gradio.live/" servers!!!

This shold be notified (on visible place) to save limited time and effords in this hot AI area at the moment!

"PHP Fatal error: Uncaught WebSocket\ConnectionException: Connection to 'wss://5585d147a4282f6f30.gradio.live/queue/join' failed: Server sent invalid upgrade response: HTTP/1.1 403 Forbidden"

1.Confirmed via shared hosting on Linux 2.Confirmed via local PC with no server Windows 10 with installed php 8.3.0, but not installed any web server!!!