avwx-rest / avwx-engine

Aviation Weather parsing engine. METAR & TAF
MIT License
90 stars 31 forks source link

empty responses #2

Closed davidobrien1985 closed 8 years ago

davidobrien1985 commented 8 years ago

Hi,

I use the API from an Azure Function (similar to AWS Lambda) to provide my travelling colleagues with some flight weather info before they drive to the airport.

However, like 4 out of 10 times the API comes back with an empty response and only after retrying several times I get an actual response with weather info. As this is used as a Slackbot, retrying multiple times is obviously not great as it destroys user experience.

Invoke-RestMethod -Method Get -Uri "http://avwx.rest/api/metar.php?station=eddk&format=JSON&options=translate,info" -Verbose
VERBOSE: GET http://avwx.rest/api/metar.php?station=eddk&format=JSON&options=translate,info with 0-byte payload
VERBOSE: received 1114-byte response of content type application/json

This is a successful response, but then like 40% of all times I get a 0-byte response back.

Any idea as to why this happens or what I can do to prevent this?

devdupont commented 8 years ago

The code infrastructure I made around the API was not designed to respond to 7K requests per minute. I have plans on how to fix it so that the number of timeout errors decrease. I am currently unable to apply them, but Azure support is currently working on it.

davidobrien1985 commented 8 years ago

Cool, thanks. For now I'll go straight to https://aviationweather.gov then. This morning (10PM UTC time) it took around 15 tries to get a valid response back.

devdupont commented 8 years ago

Hi there. I have some good news. I've finally built and deployed a test version of the new AVWX API. I'd like to hear what you think before going through the process of replacing the old version.

It's currently sitting at http://avwx-api.azurewebsites.net/ The API is the only functioning part of the test. I've changed the API structure slightly, but I hope it makes more sense than the previous one.

METAR with station: http://avwx-api.azurewebsites.net/metar/KLEX METAR with lat/lon: http://avwx-api.azurewebsites.net/api/metar/23.45,-15.65

TAF with station: http://avwx-api.azurewebsites.net/api/metar/KLEX TAF with lat/lon http://avwx-api.azurewebsites.net/api/taf/23.45,-15.65

"format" and "options" values can be URL parameters OR request headers. New format defaults to JSON.

Additionally, I made it so that the original .php endpoints will still work via routing even though there is no PHP code on the server anymore. It's pure Python.

I've also open-sourced the code of the API itself on GitHub https://github.com/flyinactor91/AVWX-API

Michael duPont

On Tue, Aug 2, 2016 at 9:33 PM davidobrien1985 notifications@github.com wrote:

Cool, thanks. For now I'll go straight to https://aviationweather.gov then. This morning (10PM UTC time) it took around 15 tries to get a valid response back.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/flyinactor91/AVWX-Engine/issues/2#issuecomment-237105811, or mute the thread https://github.com/notifications/unsubscribe-auth/ACedjQFb1dTqtxZMmwhkssxwPse-phqrks5qb-_tgaJpZM4JaPo8 .

Michael duPont mdupont.com

davidobrien1985 commented 8 years ago

@flyinactor91 does that test API still work? I just saw your feedback and tried this:

Invoke-RestMethod -Method Get -Uri "http://avwx-api.azurewebsites.net/metar/eddk" -verbose
VERBOSE: GET http://avwx-api.azurewebsites.net/metar/eddk with 0-byte payload
Invoke-RestMethod :
404 Not Found
Not Found
The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.
At line:1 char:1
+ Invoke-RestMethod -Method Get -Uri "http://avwx-api.azurewebsites.net ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
devdupont commented 8 years ago

Sorry. I forgot to put api in that specific link. This will work as do the rest. http://avwx-api.azurewebsites.net/api/metar/eddk

On Tue, Aug 23, 2016 at 8:22 PM davidobrien1985 notifications@github.com wrote:

@flyinactor91 https://github.com/flyinactor91 does that test API still work? I just saw your feedback and tried this:

Invoke-RestMethod -Method Get -Uri "http://avwx-api.azurewebsites.net/metar/eddk" -verbose VERBOSE: GET http://avwx-api.azurewebsites.net/metar/eddk with 0-byte payload Invoke-RestMethod : 404 Not Found Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. At line:1 char:1

  • Invoke-RestMethod -Method Get -Uri "http://avwx-api.azurewebsites.net ...
  • 
    - CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    - FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/flyinactor91/AVWX-Engine/issues/2#issuecomment-241922872, or mute the thread https://github.com/notifications/unsubscribe-auth/ACedjWFpXpNHAXm7aHeHVAXu8rUJmMRCks5qi47WgaJpZM4JaPo8 .

Michael duPont mdupont.com

davidobrien1985 commented 8 years ago

Alright, it works. Thanks very much. You could also maybe try running it as an Azure Function? Might make it a bit faster even?!

I've so far not seen any timeouts. :+1:

devdupont commented 8 years ago

That’s something I’ve also considered (and may test in the future). For now, I like that Falsk’s routing let’s me serve the new API design while also satisfying the old php endpoints with the same code. The Azure API App setup let’s more test potential load, so I’ll switch it over once I know it can handle the load. This should scale out (rather than up) far more gracefully than the old one.

On Aug 23, 2016, at 8:54 PM, davidobrien1985 notifications@github.com wrote:

Alright, it works. Thanks very much. You could also maybe try running it as an Azure Function? Might make it a bit faster even?!

I've so far not seen any timeouts. 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/flyinactor91/AVWX-Engine/issues/2#issuecomment-241927393, or mute the thread https://github.com/notifications/unsubscribe-auth/ACedjTLG0DptbGoighnIBqo5LLe7XFKkks5qi5YygaJpZM4JaPo8.

devdupont commented 8 years ago

The API has been updated to the new architecture. I've also released the full API code in a separate repository https://github.com/flyinactor91/AVWX-API