Closed ondrejmirtes closed 11 months ago
I'm encountering this same issue, using Mac OS Safari Version 14.1.2 (14611.3.10.1.5)
. The URL that's being visited is a normal URL that works fine in Chrome. It happens for nearly any URL I try. (I've hidden most of the host details.)
$ expose share localhost:3000 --subdomain=XXXXXX
Trying to use custom domain: XXXXXX
Thank you for using expose.
Local-URL: localhost:3000
Dashboard-URL: http://127.0.0.1:4040
Expose-URL: http://XXXXXXXXXXXX:443
Expose-URL: https://XXXXXXXXXXX
+--------+-------------------------------------------+----------+---------------------+----------+
| Method | URI | Response | Time | Duration |
+--------+-------------------------------------------+----------+---------------------+----------+
| GET | /checkout/XXXXXXXXXXXXXXXXX | | 2021-07-21 21:35:40 | 19ms |
+--------+-------------------------------------------+----------+---------------------+----------+
In Uri.php line 389:
URI is not valid and cannot be converted into a string
There's no other details being displayed for me (not even the stack trace), so I'm not sure how to debug this further. I looked for a Uri.php
in this package, but there doesn't seem to be one so I assume it's something in one of the dependencies?
I've also been looking into this issue and noticed that iOS Safari will load a tunnelled page the first time, but crash with this error on a reload/refresh. If I clear cache it will work once again, until I refresh again.
I haven't figured it out exactly, but this seems (for me anyway) to have something to do with cookies being sent alongside requests. When I disable or delete all cookies, the crashing stops. If I once again visit a site that sets a cookie and then visit a site hosted on expose, the crashing starts again. That could be similar to what @chadworthman noticed above, since the first time you visit a site the cookies would get set, and the second time they'd be sent with the request.
Also, I was able to get a stack trace by adding -vvv
to the expose command. I think it's the same as the original one posted here but I'll post mine anyway. Below the fold:
Does this happen to you for any URL that you share with Safari?
Does this happen to you for any URL that you share with Safari?
sirbrillig and I are working on the same project and are both trying to share the same URLs. I am able to crash expose by loading the page with mobile Safari on an iPhone.
It crashes while loading the first page, so it's difficult to say if it's for all URLs on a given tunnel. I added a random string to the root URL, the server managed to give me a "Page not found" message before expose crashed.
`In Uri.php line 389:
[Laminas\Uri\Exception\InvalidUriException]
URI is not valid and cannot be converted into a string
Exception trace:
at phar:///usr/local/bin/expose/vendor/laminas/laminas-uri/src/Uri.php:389
Laminas\Uri\Uri->toString() at phar:///usr/local/bin/expose/vendor/laminas/laminas-http/src/Header/AbstractLocation.php:103
Laminas\Http\Header\AbstractLocation->getUri() at phar:///usr/local/bin/expose/vendor/laminas/laminas-http/src/Header/AbstractLocation.php:128
Laminas\Http\Header\AbstractLocation->getFieldValue() at phar:///usr/local/bin/expose/vendor/laminas/laminas-http/src/Headers.php:437
Laminas\Http\Headers->toArray() at phar:///usr/local/bin/expose/app/Logger/LoggedRequest.php:185
App\Logger\LoggedRequest->getRequestId() at phar:///usr/local/bin/expose/app/Logger/LoggedRequest.php:46
App\Logger\LoggedRequest->__construct() at phar:///usr/local/bin/expose/app/Logger/RequestLogger.php:32
App\Logger\RequestLogger->logRequest() at phar:///usr/local/bin/expose/app/Client/Http/HttpClient.php:52
App\Client\Http\HttpClient->performRequest() at phar:///usr/local/bin/expose/app/Client/ProxyManager.php:81
App\Client\ProxyManager->performRequest() at phar:///usr/local/bin/expose/app/Client/ProxyManager.php:35
App\Client\ProxyManager->App\Client\{closure}() at phar:///usr/local/bin/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
Ratchet\Client\WebSocket->emit() at phar:///usr/local/bin/expose/vendor/ratchet/pawl/src/WebSocket.php:72
Ratchet\Client\WebSocket->Ratchet\Client\{closure}() at phar:///usr/local/bin/expose/vendor/ratchet/rfc6455/src/Messaging/MessageBuffer.php:248
Ratchet\RFC6455\Messaging\MessageBuffer->processData() at phar:///usr/local/bin/expose/vendor/ratchet/rfc6455/src/Messaging/MessageBuffer.php:194
Ratchet\RFC6455\Messaging\MessageBuffer->onData() at phar:///usr/local/bin/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
Evenement\EventEmitter->emit() at phar:///usr/local/bin/expose/vendor/react/stream/src/Util.php:71
React\Stream\Util::React\Stream\{closure}() at phar:///usr/local/bin/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
Evenement\EventEmitter->emit() at phar:///usr/local/bin/expose/vendor/react/stream/src/DuplexResourceStream.php:193
React\Stream\DuplexResourceStream->handleData() at phar:///usr/local/bin/expose/vendor/react/event-loop/src/StreamSelectLoop.php:245
React\EventLoop\StreamSelectLoop->waitForStreamActivity() at phar:///usr/local/bin/expose/vendor/react/event-loop/src/StreamSelectLoop.php:212
React\EventLoop\StreamSelectLoop->run() at phar:///usr/local/bin/expose/app/Client/Factory.php:193
App\Client\Factory->run() at phar:///usr/local/bin/expose/app/Commands/ShareCommand.php:59
App\Commands\ShareCommand->handle() at phar:///usr/local/bin/expose/vendor/illuminate/container/BoundMethod.php:36
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at phar:///usr/local/bin/expose/vendor/illuminate/container/Util.php:40
Illuminate\Container\Util::unwrapIfClosure() at phar:///usr/local/bin/expose/vendor/illuminate/container/BoundMethod.php:93
Illuminate\Container\BoundMethod::callBoundMethod() at phar:///usr/local/bin/expose/vendor/illuminate/container/BoundMethod.php:37
Illuminate\Container\BoundMethod::call() at phar:///usr/local/bin/expose/vendor/illuminate/container/Container.php:614
Illuminate\Container\Container->call() at phar:///usr/local/bin/expose/vendor/illuminate/console/Command.php:136
Illuminate\Console\Command->execute() at phar:///usr/local/bin/expose/vendor/symfony/console/Command/Command.php:256
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/expose/vendor/illuminate/console/Command.php:121
Illuminate\Console\Command->run() at phar:///usr/local/bin/expose/vendor/symfony/console/Application.php:971
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/expose/vendor/symfony/console/Application.php:290
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/expose/vendor/symfony/console/Application.php:166
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/expose/vendor/illuminate/console/Application.php:92
Illuminate\Console\Application->run() at phar:///usr/local/bin/expose/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Console/Kernel.php:129
Illuminate\Foundation\Console\Kernel->handle() at phar:///usr/local/bin/expose/vendor/laravel-zero/framework/src/Kernel.php:91
LaravelZero\Framework\Kernel->handle() at phar:///usr/local/bin/expose/expose:46
require() at /usr/local/bin/expose:14
`
I'm pretty sure if I tried sharing www.slevomat.cz
(not a local server but the public one) through expose, I'd be able to reproduce this. But I'm not able to do it, expose share www.slevomat.cz
doesn't work.
I've continued testing and backed out the nginx SSL proxy to use HTTP only. That worked with Chrome on Windows and Safari on iOS. I then put the nginx SSL proxy back in and re-tested. Chrome on Windows still worked, but Safari on iOS crashed it again.
I've compiled my own expose.phar with a few simple edits to the server section of config/expose.php, but the error message is now a little more descriptive:
Laminas\Uri\Exception\InvalidUriException
URI is not valid and cannot be converted into a string
at phar:///usr/local/bin/expose/vendor/laminas/laminas-uri/src/Uri.php:389
385▕ public function toString()
386▕ {
387▕ if (! $this->isValid()) {
388▕ if ($this->isAbsolute() || ! $this->isValidRelative()) {
➜ 389▕ throw new Exception\InvalidUriException(
390▕ 'URI is not valid and cannot be converted into a string'
391▕ );
392▕ }
393▕ }
+3 vendor frames
4 phar:///usr/local/bin/expose/app/Logger/LoggedRequest.php:185
Laminas\Http\Headers::toArray()
5 phar:///usr/local/bin/expose/app/Logger/LoggedRequest.php:46
App\Logger\LoggedRequest::getRequestId()
nginx config is per the recommendations at expose.dev:
root@debian-expose-vm01:~# cat /etc/nginx/sites-available/default
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name XXXX.XXXX;
# Start the SSL configurations
location / {
proxy_pass http://127.0.0.1:8080;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
# Allow the use of websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
ssl_certificate /etc/letsencrypt/live/XXXX.XXXX/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/XXXX.XXXX/privkey.pem; # managed by Certbot
}
FWIW, I traced this issue down to the laminas dependency not handling empty URIs. I updated vendor/laminas/laminas-uri/src/Uri.php to include a check and conversion:
`public function toString() {
if ($this->path == NULL) {
$this->path = '/';
}
if (! $this->isValid()) {
if ($this->isAbsolute() || ! $this->isValidRelative()) {
throw new Exception\InvalidUriException(
'URI is not valid and cannot be converted into a string'
);
}
}`
Recompiled the PHAR and tested successfully with Safari. I haven't used the package since July 2021, so I can't say if the bug still exists.
I have which is probably a related error and is clearly a problem with that dependency.
I can see the following output within the container activity.
expose_1 | Laminas\Http\Header\Exception\RuntimeException
expose_1 |
expose_1 | Malformed Cookie header found
expose_1 |
expose_1 | at vendor/laminas/laminas-httpHeader/Cookie.php:78
expose_1 | 74? $arrayInfo = [];
expose_1 | 75? foreach ($nvPairs as $nvPair) {
expose_1 | 76? $parts = explode('=', $nvPair, 2);
expose_1 | 77? if (count($parts) !== 2) {
expose_1 | ? 78? throw new Exception\RuntimeException('Malformed Cookie header found');
expose_1 | 79? }
expose_1 | 80? [$name, $value] = $parts;
expose_1 | 81? $arrayInfo[$name] = urldecode($value);
expose_1 | 82? }
expose_1 |
expose_1 | +2 vendor frames
expose_1 | 3 app/Logger/LoggedRequest.php:185
expose_1 | Laminas\Http\Headers::toArray()
expose_1 |
expose_1 | 4 app/Logger/LoggedRequest.php:46
expose_1 | App\Logger\LoggedRequest::getRequestId()
After that the tunnel breakdown.
Hi!, I stumbled upon this thread.
I'm also having the same issue with Expose 2.5.0 on mobile Safari on my Laravel app. Desktop Safari and mobile Firefox seem to not have issues.
Closing this issue because it's old. Please feel free to open a new one if it's still relevant.
I still have this problem
Hi, thank you for this amazing tool! After upgrading to v2, I am experiencing the following problem after browsing my local site shared with expose:
Version: Expose 2.0.2
This is the stack trace:
Unfortunately I don't know what kind of URL is requested by the browser, it happens only when I'm browsing with mobile Safari...