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

ipfshttpclient.exceptions.StatusError: HTTPError: 405 Client Error: Method Not Allowed for url: http+ip4://127.0.0.1:5001/api/v0/version?stream-channels=true #218

Closed
avatar-lavventura opened this issue Jun 3, 2020 · 16 comments

Comments

@avatar-lavventura
Copy link

avatar-lavventura commented Jun 3, 2020

ipfs version 0.5.1
ipfshttpclient-0.4.13.2


Ipfs is already running on the background using (nohup ipfs daemon &). Afterwards I tried to obtain already connected ipfs's client.

$ ipfs config Addresses
{
  "API": "/ip4/127.0.0.1/tcp/5001",
  "Announce": [],
  "Gateway": "/ip4/127.0.0.1/tcp/8080",
  "NoAnnounce": [],
  "Swarm": [
    "/ip4/0.0.0.0/tcp/4001",
    "/ip6/::/tcp/4001"
  ]
}

import ipfshttpclient

client = ipfshttpclient.connect('/ip4/127.0.0.1/tcp/5001/http')

=> What may be the reason of this error? How could I fix it?


Error log:

❯ ./ipfs_daemon.py
[2020-06-04 02:48:12          lib.py:314 -         is_process_on()] IPFS is already running on the background
Traceback (most recent call last):
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/http.py", line 266, in _do_raise_for_status
    response.raise_for_status()
  File "/home/alper/venv/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: http+ip4://127.0.0.1:5001/api/v0/version?stream-channels=true

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./ipfs_daemon.py", line 30, in <module>
    client = ipfshttpclient.connect('/ip4/127.0.0.1/tcp/5001/http')
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/client/__init__.py", line 101, in connect
    version_str = client.version()["Version"]
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/client/base.py", line 15, in wrapper
    result = func(*args, **kwargs)
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/client/miscellaneous.py", line 204, in version
    return self._client.request('/version', decoder='json', **kwargs)
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/http.py", line 51, in wrapper
    return func(self, *args, **merged)
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/http.py", line 386, in request
    username, password, data, timeout)
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/http.py", line 307, in _request
    self._do_raise_for_status(res)
  File "/home/alper/venv/lib/python3.7/site-packages/ipfshttpclient/http.py", line 286, in _do_raise_for_status
    six.raise_from(exceptions.StatusError(error), error)
  File "<string>", line 3, in raise_from
ipfshttpclient.exceptions.StatusError: HTTPError: 405 Client Error: Method Not Allowed for url: http+ip4://127.0.0.1:5001/api/v0/version?stream-channels=true
@leex404
Copy link

leex404 commented Jun 4, 2020

same issue. Don't know how to fix it !

@mike7c2
Copy link
Contributor

mike7c2 commented Jun 9, 2020

I bumped into this too but it went away away updating my nodes. I think that the PIP version of ipfshttpclient is very out of date.

I'm currently using latest py-ipfs-http-client (actually a forked branch which has "diff" added: https://github.com/mike7c2/py-ipfs-http-client )

With go-ipfs 0.5.1 and it's all working fine

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Jun 9, 2020

I am also using ipfs version 0.5.1 but it still generates the same error

@AliabbasMerchant
Copy link
Member

AliabbasMerchant commented Jun 9, 2020

@ntninja I think you will have to update the pip package

@mike7c2
Copy link
Contributor

mike7c2 commented Jun 9, 2020

Note that I'm not running the version from PIP, I have cloned and built the latest, It works fine building from 5e3edf5f8e9e117738c77b5773c78d7b48942bc2 on the main repo.

@ianwaldrop
Copy link

ianwaldrop commented Jun 10, 2020

these requests work as posts, per the docs;

A 405error may mean that you are using the wrong HTTP method (i.e. GET instead of POST), or that you are not allowed to call that method (i.e. due to CORS restrictions when making a request from a browser).

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Jun 10, 2020

@AliabbasMerchant: I am using pip 20.1.1 (I think it is the latest version).
@ianwaldrop: How can I make it use POST instead of GET?

@AliabbasMerchant
Copy link
Member

AliabbasMerchant commented Jun 10, 2020

@avatar-lavventura I am not referring to the version of pip, but to the version of our package on pip.

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Jun 10, 2020

@AliabbasMerchant What is the version of your package on pip I should try?

@ntninja
Copy link
Contributor

ntninja commented Jul 1, 2020

Should be fixed in 0.6.0

@ntninja ntninja closed this as completed Jul 1, 2020
@avatar-lavventura
Copy link
Author

avatar-lavventura commented Jul 1, 2020

@ntninja Thank you for considering the issue and solving it.

@sohansoharab
Copy link

sohansoharab commented Nov 21, 2020

Can you please provide a good documentation link on ipfshttpclient?
https://ipfs.io/ipns/12D3KooWEqnTdgqHnkkwarSrJjeMP2ZJiADWLYADaNvUb6SQNyPF/docs/ is not working . Please provide it ... it would be so much helpful
@ntninja

@ElberQiao
Copy link

ElberQiao commented Feb 14, 2021

I am stiil stuck by this problem with IPFShttpclient 0.6.0
I use the postman to test the POST method for the same request and it works out fine, but there is no args to specify the method using .connect()...
Is there any alternative way?


solved by degrade my IPFS version to 0.6.0

@Yuki23329626
Copy link

Yuki23329626 commented Sep 19, 2021

I think the key to this issue is the compatibility of go-ipfs and IPFShttpclient.
Actually I change the version of go-ipfs and IPFShttpclient both to v0.6.0 and it works.
Also works if both version is v0.8.0.

Set the python package of IPFShttpclient with its version:
pip install ipfshttpclient==0.8.0

Download and install the compatible verision of go-ipfs on your machine:
download go-ipfs-zip

@avatar-lavventura
Copy link
Author

avatar-lavventura commented Sep 19, 2021

@Yuki23329626 Currently latest ipfs version is 0.9.0: #296

@xapillox
Copy link

xapillox commented Jan 17, 2022

go-ipfs daemon version and ipfshttpclient version should be same e.g v0.8.0 or v0.6.0.

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

10 participants