Bad Requests behind a proxy since version 5.3.4 #4016
Comments
Thanks for reporting this. We'll get this on our backlog to see what's going wrong here. You're probably right about the change to the axios library. But we'll do further digging to see if we can't fix the issue. Sorry about this! |
I found an option for axios, |
@ityreh We just released a new version of Truffle (5.3.6). It might fix your issue, could you please upgrade and let us know whether it does? Thank you! |
@eggplantzzz thank you, but I get the same error with version |
Hmm, I thought that increasing the amount of allowable redirects might solve it...I wonder what could be causing this. |
Can you tell us anything more about your setup? I'm not sure how involved it would be for us to reproduce your error. I guess we'll have to look into the axios options again and maybe compare them to what request is doing. |
Hey guys, I'm a colleague of Yannick and I have the same problem. Our environment is a heavily restricted enterprise environment, but the http proxy is nothing special. All tools that use the "http_proxy" environment variable work with it, e.g. curl. Other tools that provide proxy settings with an "http proxy" option also work with it, e.g. npm. We already know that truffle stopped working when the http client was migrated to axios. And I've found that axios has two modes regarding proxy settings:
Please see this axios issue for more information. |
Hey thanks for the information @thorstenhirsch! I'm going to look into it directly. In this case it looks like the proxy object is used for you to customize where the request will be sent with the idea that it will be handled and sent by whatever is listening there. Does this mean in these cases that the user will be required to enter in their own custom info to use here? This doesn't seem great. |
Maybe we need something like this...
But first I'd suggest to take a look into the code of the old http client (which was used before the migration to axios), because I think that the old one solved the task perfectly. There might be some quirks related to the http_proxy variable, because there might also be https_proxy. And I don't know which one to prefer, because in our environment there's no difference between them. Others might do. It's a bit unfortunate that axios lacks this feature and we need to implement it ourselves. Maybe axios wasn't supposed to be run in other runtimes than the browser...? |
Yeah this should be something that we can solve. Do you really think it has something to do with setting up the proxy object? The old lib did it by itself without any extra setup and so I would assume it should be something we can set and forget. I'll go back to the old lib and see what it does differently under the hood. |
So I did some digging with a colleague and understand a little bit better how axios and request handle some of the proxy details. request seems to have a much more robust handling of the environment variables. It looks like request handles "http_proxy" and "https_proxy" but it doesn't look for the other variants such as "HTTPS_PROXY". I am curious to see how your environment is set up. Would you be able to open a terminal and see which ones are populated? That would be something like The other possibility is that axios won't handle username/password stuff but it doesn't look like request handles that out of the box without some extra information passed to it. Truffle had a bare bones implementation that didn't include passing request any auth info. |
I'm on Windows (unfortunately) and I've set |
What happens if you populate the |
Setting
Without |
Hmm, ok. How easy is it to setup a proxy situation like you have there? I would love to be able to duplicate a setup like that locally here to test and hopefully solve this issue. |
Unfortunately I don't know what software our http proxy server is using, but since it works with default http proxy settings on the client I guess it's something like squid. I guess you don't even need to enable user authentication to reproduce the problem. |
So we were able to cook up a minimal example proof of concept here locally using http toolkit. In the environment we needed to populate There was also no username/password-type auth involved here. The original error by the OP was 400 error which means that there is something bad about the request - this 400 might be coming from the proxy server itself? I'll keep thinking about this problem and see if I can think of any way to proceed on troubleshooting this. Let me know if you have any ideas or can get any more useful information about this issue. Thanks! |
I think the bug behind this pull request is causing the 400 error. We've exactly the same setup: our https_proxy is reached via http. So if axios creates an https request it's the wrong protocol for an http listener, thus 400 is expected. Unfortunately the PR hasn't been merged into axios, yet. |
Alright, I did some further investigation and it seems like it's already fixed in the latest version of axios thanks to this commit. So we only need to update the dependencies from axios v0.20.0 to v0.21.1. edit: I see that packages/*/package.json already depend on axios v0.21.1 ( |
Oh sweet! That PR should fix this issue you think? Did you ever narrow down exactly what was causing it? I'll go ahead and put in a PR to update this. Thanks for helping me troubleshoot this issue @thorstenhirsch! |
@thorstenhirsch I just checked and Truffle is actually using version What happens is that Truffle gets bundled by webpack and that bundled file ends up getting run when you do |
I'm still doing some research on this. I wonder if it has something to do with the fact that the target specifies |
Having this issue in 5.3.12 |
It is still a problem in Truffle v5.4.5 |
Hello, I still have this issue with linux in Truffle v5.4.11 |
Hello, i am also running into this problem on Windows with Truffle v5.4.11 |
Same issue for me with the latest version. I use the
|
@nyg, @UISebastian can you run the unbox command with DEBUG enabled and share the output? |
@cds-amal Thanks for looking into it! :) Here you go:
I see that the Axios version is still 0.21.1. Looking at the previous comments, the issue may have been fixed in more recent versions (it might just be a question of updating the dependency). |
the same:
|
@cds-amal another same error.
|
just add raw.githubusercontent.com to no_proxy env var. |
I'm getting the same errors as above on a corporate-proxied Linux machine. I downgraded to Truffle 5.3.3, installed axios-https-proxy-fix, and added raw.githubusercontent.com to my no_proxy, all with no success. |
I found a workaround to the issue while using Truffle behind a proxy. Download a version of the solc compiler from https://github.com/ethereum/solc-bin/tree/gh-pages/bin and put it in the folder that Truffle stores its compilers in (on Linux this is ~/.config/truffle/compilers/node_modules... I don't know Windows/mac!).
Listing the compiler versions still returns the 407 error:
But when using
Hopefully this workaround is useful until the error is fixed & the issue is closed! |
Is this still an issue on the latest Truffle (v5.5.10)? We recently updated axios, they may have updated something that will now allow this to work. Can anyone let me know? |
Yes, it is still a problem with version v5.5.10 |
It is still a problem with v5.5.16 |
Thanks @alexspringgit and @tonguyengit for confirming! |
I modified the code and did a pull request: #5847 |
So axios was once again updated in Truffle and it looks like there was some fix that is related to this issue. Can anyone check on the latest Truffle (v5.7.4) once more to see if this has been resolved? Thanks! |
So there is a PR out to fix this issue here. Can anyone here verify this fix on that open PR? We haven't yet created a way to test this. @alexspringgit @tonguyengit ? |
Issue
Using a truffle operation on a Windows System with truffle version
5.3.4
, that sends a HTTP request, you get a Bad Request Error. My Windows System is behind a proxy.Maybe the switch to axios in
5.3.4
is causing this issue.Steps to Reproduce
Upgrade your truffle version to
5.3.4
and try to use an operation that sends a HTTP request, e.g.truffle unbox metacoin
or in an existing projecttruffle compile --list
.Expected Behavior
Truffle does not send bad requests.
Actual Results
One of the operations that sends a bad request ist
truffle compile --version
.Output with version
5.3.4
(not working):Output with version
5.3.3
(working):Environment
truffle version
): 5.3.4node --version
): 16.1.0npm --version
): 7.11.2The text was updated successfully, but these errors were encountered: