Non-Numeric Value encountered
I had been up and running with you proxy for about a month now on an AWS box with load balancer and Laravel on backend. After an upgrade (at 3.3 now) now getting an error:
ErrorException in TrustProxies.php line 159:
A non-numeric value encountered
in TrustProxies.php line 159
at HandleExceptions->handleError('2', 'A non-numeric value encountered', '/home/forge/isdb.io/code/Laravel/vendor/fideloper/proxy/src/TrustProxies.php', '159', array('set' => '0', 'key' => 'forwarded')) in /home/forge/isdb.io/code/Laravel/vendor/fideloper/proxy/src/TrustProxies.php line 159
at TrustProxies->Fideloper\Proxy\{closure}('0', 'forwarded')
Scratching my head with no clue whats happening....any help would be appreciated.
Thx
DJK
There's here: https://github.com/fideloper/TrustedProxy/blob/master/src/TrustProxies.php#L159
It's doing bitwise math on values which apparently are non-numeric.
Can you let me know what version of Laravel and Symfony are being used? (composer.lock may have information on the actual versions installed for laravel/framework and symfony/http-kernel).
"name": "laravel/framework", "version": "v5.3.31", not sure if this is correct Symfony entry but: "name": "symfony/http-kernel", "version": "v3.1.10",
I did notice the config file probably got overwritten since that ip address for proxie should have been '*' I believe.....but changing that did not make error go away.
We just updated and we are receiving the same error on our local dev machine, but it seems to be okay on our AWS instance behind the load balancer. Here is our json.lock:
"name": "fideloper/proxy", "version": "3.3.2",
"name": "laravel/framework", "version": "v5.3.31",
"name": "symfony/http-kernel", "version": "v3.1.10",
Here is the stack trace (ours is a bit different in array('set' => '0', 'key' => 'client_ip'):
in TrustProxies.php line 159 at HandleExceptions->handleError('2', 'A non-numeric value encountered', '/home/vagrant/Code/HowLikely.com/vendor/fideloper/proxy/src/TrustProxies.php', '159', array('set' => '0', 'key' => 'client_ip')) in TrustProxies.php line 159 at TrustProxies->Fideloper\Proxy{closure}('0', 'client_ip') at array_reduce(array('client_ip', 'client_host', 'client_proto', 'client_port'), object(Closure), '0') in TrustProxies.php line 160 at TrustProxies->getTrustedHeaderSet() in TrustProxies.php line 97 at TrustProxies->setTrustedProxyIpAddressesToSpecificIps(object(Request), array('10.70.1.0/24', '10.70.2.0/24', '10.70.3.0/24', '10.70.4.0/24')) in TrustProxies.php line 69 at TrustProxies->setTrustedProxyIpAddresses(object(Request)) in TrustProxies.php line 54 at TrustProxies->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 46 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 104 at Pipeline->then(object(Closure)) in Kernel.php line 150 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117 at Kernel->handle(object(Request)) in index.php line 53
Interesting! Can you show me the laravel and symfony version as well? On Tue, May 30, 2017 at 18:05 zakkyzebra [email protected] wrote:
We are receiving the same error on our local dev machine, but it seems to be okay on our AWS instance behind the load balancer. Here is our json.lock:
"name": "fideloper/proxy", "version": "3.3.2",
"name": "laravel/framework", "version": "v5.3.31",
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/fideloper/TrustedProxy/issues/74#issuecomment-305033564, or mute the thread https://github.com/notifications/unsubscribe-auth/AAch03bcWhUGcgUKmrivhuXJD7YLam5Dks5r_KCfgaJpZM4NquCO .
Since my site is down I had to "do" something. So I upgraded to latest Laravel 5.4. Fine on devel machine but on AWS getting new error:
The Symfony\Component\HttpFoundation\Request::setTrustedProxies() method expects a bit field of Request::HEADER_* as second argument. Defining it is required since version 3.3. See http://symfony.com/doc/current/components/http_foundation/trusting_proxies.html for more info.
InvalidArgument exception.
Thoughts?
DJK
That's the error receoved the setTrustedProxies has no 2nd argument. That shouldn't be the case in version 3.3.2 of this package - did this package get updated as well? On Tue, May 30, 2017 at 18:23 Dean Kaplan [email protected] wrote:
Since my site is down I had to "do" something. So I upgraded to latest Laravel 5.4. Fine on devel machine but on AWS getting new error:
The Symfony\Component\HttpFoundation\Request::setTrustedProxies() method expects a bit field of Request::HEADER_* as second argument. Defining it is required since version 3.3. See http://symfony.com/doc/current/components/http_foundation/trusting_proxies.html for more info.
InvalidArgument exception.
Thoughts?
DJK
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/fideloper/TrustedProxy/issues/74#issuecomment-305036827, or mute the thread https://github.com/notifications/unsubscribe-auth/AAch0xgE1E9wzpqc90HtI1k4HoNLJ9WCks5r_KTUgaJpZM4NquCO .
Chris,
Turns out I had some middleware in there that forces https. Not in your code.
Interesting (slight off topic but you might know why this is occurring). What was working before now gets "too many redirects". My code:
public function handle($request, Closure $next) { if (!app()->environment('local')) { // for Proxies Request::setTrustedProxies([$request->getClientIp()], $this->getTrustedHeaderSet());
if (!$request->isSecure()) {
return redirect()->secure($request->getRequestUri());
}
}
return $next($request);
}
Thanks for the help.
DJK
I'm getting this error too after upgrading to 3.3.2.
- Laravel v5.3.31
- PHP 7.1
Same here.
- Laravel 5.3.31
- PHP 7.1
I downgraded to 3.3.1 from 3.3.2, it is fine.
Me too.
- Laravel 5.1
- PHP 7.1
3.3.1 is ok.
Once Github issues clear up, I'll push up a fix to this :D
Release 3.3.3 created to resolve this, let me know if you run into any issues!
https://github.com/fideloper/TrustedProxy/releases/tag/3.3.3