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

New Datasource: Fastah IP API #81

Closed
s8mathur opened this issue Mar 29, 2020 · 10 comments
Closed

New Datasource: Fastah IP API #81

s8mathur opened this issue Mar 29, 2020 · 10 comments

Comments

@s8mathur
Copy link
Contributor

Hello,

Would contributions be welcome for an additional REST API as a data source/backend?

I am the developer of the above API. We at Fastah intend to keep it as a paid offering with a credible support plan (there is a no-cost, 30-day trial available)

How it compares to what's already part of YellowTree
a) mobile IPs coverage - constantly being enhanced, and includes IPv6 deployments by mobile carriers
b) security in transit - HTTPS with TLS1.2+ as the only transport option
c) performance: HTTP/2 out of the box to enable request/response multiplexing. Open to adding in-memory caching to the client-side.

Please let me know if this would be a good idea :)

Sid

@benjaminpick
Copy link
Member

benjaminpick commented Mar 31, 2020 via email

@s8mathur
Copy link
Contributor Author

Hey Benjamin,

I have picked this up again, current work-in-progress branch is here. Any guidance on which HTTP client to use? Is it OK to require availability of PHP-Curl and associated curl_init()?

The Fastah API endpoint requires TLS 1.2 and recommends HTTP/2 for performance (and concurrency) , so it would be desirable for this data-provider implementation to use the best possible HTTP/2 client that can be reasonably packed with the plugin or expected to be available in the host installation. Recommendations? :)

About your example response question, the REST API response is as follows:

{
	"ip": "200.38.122.55",
	"isEuropeanUnion": false,
	"locationData": {
		"countryName": "Mexico",
		"countryCode": "MX",
		"cityName": "Mexico City",
		"cityGeonamesId": 3530597,
		"lat": 19.44,
		"lng": -99.14,
		"tz": "America/Mexico_City",
		"continentCode": "NA"
	}
}

Note that only 'en' locale is currently returned. Would be this be good enough to start with?

Will send you a trial key too! :)

@benjaminpick
Copy link
Member

benjaminpick commented Sep 29, 2021 via email

@s8mathur
Copy link
Contributor Author

I can definitely use the core Wordpress HTTP functions for maximum portability, documentation is great.
Since their core library (above) makes no mention of HTTP/2 support, I will need a parallel Curl implementation in addition to the former?

@benjaminpick
Copy link
Member

I have looked at your code - yes it's going in a good direction, keep the stream_context. You will need to adjust the error messages accordingly (wp_get_remote should always so the plugin is not requiring curl per se - HTTP/2 support is not required but recommended etc.)

Instead of letting them choose an option that is not available on their server, you can show a message "HTTP/2 is not supported on your server. (needed libcurl version: )" and grey out the option. (It is still possible that the option is on and no HTTP/2 support, because the website might be developed locally and then pushed onto another machine.)

@s8mathur
Copy link
Contributor Author

Understood, thank you.
The core HTTP classes seems to auto-detect Curl, so one implementation is what I will do.

@s8mathur
Copy link
Contributor Author

s8mathur commented Oct 6, 2021

Hey @benjaminpick
A pull request is ready for your review.
Additionally, I have sent you an invite email to the Fastah API Developer Console which allows you to fetch API keys associated a subscription (you may rotate keys, see API success stats, origin, latency etc via this portal).
Thanks,
Sid

@s8mathur
Copy link
Contributor Author

s8mathur commented Jan 17, 2022

Hi Benjamin,
I have written a short PHP snippet to generate HTTP/2 requests using both curl_init() and curl_multi_init().

Summary of observations:

  • PHP 7/8 + Curl 7.68.0 are working well with HTTP/2 servers in curl_init() mode - I suggest we stick to curl_init() only at this time in the plugin. Observed latencies are the same as network RTT between host and server - which is as good as it gets.
  • curl_multi_init() is showing very high delays - I have tried two HTTP/2 servers and the PHP-Curl implementation or my script is doing something wrong in both cases. So we should stay away from CurlMultiHandle until resolved.

Gist is here, feel free to use :)
https://gist.github.com/s8mathur/c9697b0008d407f5f1b5b8f4c5f9da9b

PS: You may the following command to find network RTT from your host to the HTTP/2 listed in the gist above:
sudo nmap -sP -PS443 yoda.api.getfastah.com

@benjaminpick
Copy link
Member

Again, I can't imagine this plugin would profit from multiplexing, as in most use cases, there will be only 1 Fastah request per PHP call.
Nmap RTT is ~220ms for me.
Yes we can replace wp_remote_get with curl_init. You can build it in by cloning my fastah branch.

@s8mathur
Copy link
Contributor Author

Let's ship it the way it is now in the 'fastah' branch (your preferred v1 implementation). Once we get some real world usage, I will iterate on this based on user needs. Thank you.

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

2 participants