Server settings for webhooks
Webhooks are a great way to get real-time data from FsHub sent directly to your own website, virtual airline system or other web-based applications and web hooks are yet another free feature that FsHub provides both at a “user” level and “virtual airline” level.
There are however some issues that you may run into and therefore you should read the below information if you are unable to get webhooks to successfully receive to your server.
Ensuring your server can accept a large payload (POST request)
Depending on your web server setup there are several places that may limit and/or prevent large HTTP POST requests from being successfully received by your website, application or scripts, these are as follows:
- Unordered List ItemWeb Server Configuration files (eg. Apache HTTPD or Nginx virtual host or global configuration files)
- Unordered List ItemApplication Server settings (eg. PHP.ini)
- Reverse proxy or load-balancer configuration - Less likely to affect you unless you have a very complex setup!
Whilst there are too many application frameworks, web and application servers for me to go over where and what settings you need to change to enable larger HTTP POST requests, I will however cover what settings you should update for PHP as this is probably the most common language that is used by the vast majority of hobbyists and virtual airlines….
PHP is a common programming language and is widely supported by main web hosting providers but by default, out of the box, PHP will only support a HTTP POST request up to a maximum of 2MB in size, Whilst the majority of the FsHub webhooks will not send a payload larger than 2MB, the flight.completed webhook can get very large due to it sending geographical data too.
The settings that you should change (and I would recommend setting each of these values to at least 32MB - If any of these settings are already set higher, leave as they are), should be found in your PHP.ini file as follows:
memory_limit = 32M
post_max_size = 32M
upload_max_filesize = 32M
In addition to the PHP settings being updated, some web server configuration files will also prevent large POST request payloads too and as such, two common web servers are Nginx and Apache HTTPD that are commonly used with PHP, you should ensure that your web servers have the same size value added as demonstrated below:
For Nginx:
server {
…
client_max_body_size 32M;
}
For Apache HTTPD
LimitRequestBody 33554432
If you cannot increase the maximum supported POST request size you may wish to change from using flight.completed to flight.arrived instead, this will give you far less information but will enable you to get notified of an arrival.
CSRF protection
If you are using a modern web application framework such as Laravel, ASP.NET, Django, Ruby On Rails and others, these frameworks, by default may implement CSRF protection and as such, will prevent HTTP POST requests from being accepted by the server without “route exceptions” being added.
This is a topic that you should investigate if you realise that you are unable to successfully process the incoming FsHub webhooks.