Skip to content

fix(api): force IPv4 for MOFH requests#209

Closed
zhshimul815 wants to merge 5 commits intomahtab2003:devfrom
zhshimul815:dev
Closed

fix(api): force IPv4 for MOFH requests#209
zhshimul815 wants to merge 5 commits intomahtab2003:devfrom
zhshimul815:dev

Conversation

@zhshimul815
Copy link

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.

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.
Copy link
Contributor

@itsmerosu itsmerosu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove hyperlinks

@sonarqubecloud
Copy link

@santydesignscr
Copy link
Collaborator

I will merge if it doesn't modify our README, please fix that to merge

@BastelPichi
Copy link
Contributor

this can be closed, mofh does support ipv6 now.

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

Successfully merging this pull request may close these issues.

6 participants