fix(api): force IPv4 for MOFH requests#209
Closed
zhshimul815 wants to merge 5 commits intomahtab2003:devfrom
Closed
fix(api): force IPv4 for MOFH requests#209zhshimul815 wants to merge 5 commits intomahtab2003:devfrom
zhshimul815 wants to merge 5 commits intomahtab2003:devfrom
Conversation
MOFH API only supports IPv4 requests, but in some hosting environments both IPv4 and IPv6 are available. This caused issues when requests defaulted to IPv6. Updated the constructor to explicitly force IPv4 resolution when initializing the Guzzle client: - Added `use GuzzleHttp\Client as Guzzle;` - Modified client initialization to: `$this->m = new Client(new Guzzle(['force_ip_resolve' => 'v4']));` This ensures consistent API communication with MOFH by preventing failed requests caused by IPv6 resolution.
greenreader9
approved these changes
Sep 6, 2025
|
Collaborator
|
I will merge if it doesn't modify our README, please fix that to merge |
Contributor
|
this can be closed, mofh does support ipv6 now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



MOFH API only supports IPv4, but on some hosting environments where both
IPv4 and IPv6 are available, API requests could default to IPv6 and fail.
I was using this code myself and faced the same issue when calling the MOFH API.
To fix this, I updated the client initialization to force IPv4 for all API calls:
$this->m = new Client(new Guzzle(['force_ip_resolve' => 'v4']));
This ensures stable communication with MOFH and prevents failed requests
caused by IPv6 resolution.