Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug #142

Open
zgelici opened this issue Jul 7, 2019 · 12 comments
Open

Possible bug #142

zgelici opened this issue Jul 7, 2019 · 12 comments

Comments

@zgelici
Copy link

zgelici commented Jul 7, 2019

Hi,

I get an issue with a part of code. i did some checks.

vendor\torann\geoip\src\Services\IPApi.php

Line 74 gives notice:

Notice: Trying to get property 'status' of non-object

current code:

if ($json->status !== 'success') {
            throw new Exception('Request failed (' . $json->message . ')');
        }

i think this will solve it:

if ($json && $json->status !== 'success') {
            throw new Exception('Request failed (' . $json->message . ')');
        }

I get the issue when i call this:

geoip()->getLocation($ip)['country']

i dont get the notice everytime.

@jadjoubran
Copy link

I'm also getting that sometimes

@lamalamaMark
Copy link

We experience this error also frequently. @zgelici can you make a pull request containing your fix?

@zgelici
Copy link
Author

zgelici commented Aug 4, 2019

We experience this error also frequently. @zgelici can you make a pull request containing your fix?

I did it

@lamalamaMark
Copy link

I think the solution needs to be worked out further because the code after this condition also relies on the content of the $json variable. Did you look at that part?

@zgelici
Copy link
Author

zgelici commented Aug 5, 2019

@lamalamaMark

You are right, the other part need to be also inside $json check, but than its possible that the api or something gives empty results. What effect it will have.

@zgelici
Copy link
Author

zgelici commented Aug 5, 2019

@lamalamaMark can you check now the new pull request

its possible that requests or something fails, so i did multi tries. if not it give empty. i didnt test it and its late here. tomorrow evening i will check my code again. but i already did push.

@paulocastellano
Copy link

I have same problem, sentry always alarm it.

@JexPY
Copy link

JexPY commented Oct 21, 2019

Same situation with sentry, but this is happening after update from Laravel 5.8 to 6.0

@huesoamz
Copy link

@lamalamaMark the fix of @zgelici its very useful why dont accept that PR?

@gutitrombotto
Copy link

Hi guys!

I have te same problem.

Did you find the solution?

@wlepinski
Copy link

wlepinski commented May 23, 2020

I just had the same problem today.
And I think it is related to the rate limiters defined here.

Usage limits
This endpoint is limited to 45 requests per minute from an IP address.

If you go over the limit your requests will be throttled (HTTP 429) until your rate limit window is reset. If you constantly go over the limit your IP address will be banned for 1 hour.

The returned HTTP header X-Rl contains the number of requests remaining in the current rate limit window. X-Ttl contains the seconds until the limit is reset.
Your implementation should always check the value of the X-Rl header, and if its is 0 you must not send any more requests for the duration of X-Ttl in seconds.

We do not allow commercial use of this endpoint. Please see our pro service for SSL access, unlimited queries and commercial support.

While the PR proposed solves the problem with the non-object error it does not solve the problem of going above the limit on a non-paid environment.

@hosamalzagh
Copy link

same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants