REST API Errors 520, solved with a proxy

Hi,

Recently lot of my APIs calls stopped working, for example https://deep-index.moralis.io/api/v2/0x54331cf97e31b1ab3532026b884b57af0590f1cc/logs?chain=bsc&offset=0&topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&to_date=2022-03-09%2011:59:43

I always get weird errors like 520 response code or ā€œcURL error 18: transfer closed with outstanding read data remainingā€. And I didnā€™t change anything, was working all well beforeā€¦

Can you please investigate on this?

Thanks in advance

how do you make those requests?

if works fine for me now when I test it in web3api interface

It happens randomly I just had the case again with ā€œhttps://deep-index.moralis.io/api/v2/0xe8a00ad589b5bda02c7bc9bba249445d1f53d50b/logs?chain=bsc&offset=0&to_date=2022-03-09%2014:01:01ā€ => "cURL error 18: transfer closed with outstanding read data remaining "

This one just return 520 bad gateway ā€œhttps://deep-index.moralis.io/api/v2/0x1460c3ebace5b85d19e868af01faa458baef76b1/logs?chain=bsc&offset=0&topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&to_date=2022-03-09ā€

I just do normal requests with Guzzle PHP library and everything was working well but errors suddenly happened recently

I made 50 requests to this url now, I didnā€™t get any errors, also it doesnā€™t return data for this particular to_date

This one works well againā€¦ The other one still give me an error

@cryptokid This is what I get sometimes when I test within the interface. I never encountered that before this weekendā€¦

Undocumented errorā€¦

I tested with this https://deep-index.moralis.io/api/v2/0xe8a00ad589b5bda02c7bc9bba249445d1f53d50b/logs?chain=bsc&offset=0&to_date=2022-03-09%2014:01:01 100 times from a python script and I didnā€™t get any error

I definitely think there is something going on Moralis serversā€¦ these are purely random errors

it could be, how can I replicate that?
what do you do to replicate it?

Hum nothing fancy, I just use the parameters as shown above and try the request a few times. Sometimes work, sometimes notā€¦

I am still not able to replicate it.
someone else seems like also has a similar problem: Deep Index Errors: 520, 502

Yes I saw this one but no solution at the moment because you were not able to replicate as well. If someone else can have a look would be great, I donā€™t think itā€™s an isolated case

this is the only endpoint that has this problem?

This works:

This doesnā€™t:

Maybe itā€™s something related to response content length. I mostly use logs endpoint but I also get this error while fetching ā€œpair createdā€ event with the rest api

I still get some errors 502 Bad gateway from the Moralis interface itself as follow:

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/0x8482a932536fad492dcdbcedeb60cb9421ac384b/logs?chain=bsc' \
  -H 'accept: application/json' \
  -H 'X-API-Key

How is that possible?

Did you try to run the requests from another network/IP?

Yes and get the same error from another IP and network

When I debug the interface with the following simple query:
https://deep-index.moralis.io/api/v2/0x8482a932536fad492dcdbcedeb60cb9421ac384b/logs?chain=bsc

I get this error in my dev console:
ā€œnet::ERR_HTTP2_PROTOCOL_ERROR 200ā€

Any change in your Nginx config or related to HTTP2 or content length response header recently?

I got this in response as headers:

Response
:status: 200
Content-Type: application/json; charset=utf-8
Access-Control-Allow-Origin: *
Content-Encoding: gzip
ETag: W/"4f78a-qioR7lLRxZrkIRJFzXaMZYwem9k"
Date: Wed, 06 Apr 2022 11:59:07 GMT
Vary: Accept-Encoding
x-rate-limit-limit: 25
x-rate-limit-used: 2
x-powered-by: Express
Server: cloudflare
x-request-weight: 2
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
x-rate-limit-remaining-ip-ttl: 1
cf-ray: 6f7a5b08db188ce2-EWR
x-rate-limit-remaining-ttl: 1
x-rate-limit-ip-used: 2

what do you do to get that error?

I found a workaround. I created a proxy API to communicate with your API rather than calling it directly and everything looks to work fine againā€¦