So getting an odd error:
If I replace localhost with say google.com, it works fine. But if I use http://localhost/blah or http://127.0.0.1/blah I get this error. Trying to make calls to a local API I am developing. Any hints?Code:ConnectFailure (The requested address is not valid in its context. )
Thanks in advance!
Fixed Can't seem to get webrequest.Enqueue to connect to localhost
Discussion in 'Rust Development' started by MrPoundsign, Jul 24, 2018.
-
Maybe try using you local rooter adress or your real ip while you are trying to connect.
Also pasting your code could help to find a solution. -
Code:webrequest.Enqueue("http://localhost:9090/", null, (code, response) => { Puts($"{code} {response}"); }, this, RequestMethod.GET, null, 100f);
Code:ConnectFailure (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
Using "http://127.0.0.1/" fails with the "context" error above.
I can use the local hostname (machine name), but that's a work-around that I don't know if it will work on my Linux servers. Tried adding an entry into System32/etc/hosts that points to 127.0.0.1 and that fails.
All the localhost/127.0.0.1/127.0.1.1/etc work perfectly fine in web browsers / curl.
It really seems like webrequest.Enqueue has a problem with anything that resolves to the local loopback address.
[DOUBLEPOST=1532427161][/DOUBLEPOST]Just to verify, also tried with my local IP (192.168.x.x) and that worked.Last edited by a moderator: Jul 24, 2018 -
Try to up web server on standart port (80) and add line to hosts file like 127.0.0.1 localhost, reboot your system and try. This code must works:
Code:webrequest.Enqueue("http://localhost/", null, (code, response) =>
Also try with differend names in hosts file, for example: 127.0.0.1 test.loc test.com ... -
Calytic Community Admin Community Mod
OxideMod/Oxide.Core
As you can in the link above, the WebRequests library in Oxide simply uses the underlying HttpWebRequest class provided as part of .NET in System.Net. Whether or not a particular endpoint is valid has to do with the native networking of your OS and the ability (or lack thereof) of .NET to integrate with said networking. It has very little to do with Oxide itself and as such there isn't much, if anything, we can do about it, sorry. -
It's binding the client to an IP, which cannot get to localhost. Perhaps making an option Enqueue that doesn't do this would be useful for anyone working on anything that isn't a public facing IP or on the same network as the IP the server is bound to?
I understand the usefulness of this, allowing you to specify the IP the client is coming from more multi-tenant systems. But it would be nice to be able to override it to avoid this behavior, if it would allow connecting to localhost. Again, this is just what I suspect.
Just for reference, i am running on Windows 10. I have tried setting the server IP to 127.0.0.1, my local LAN IP, and 0.0.0.0 -
Wulf Community Admin
This functionality is key for preventing any servers with multiple network adapters from using the primary adapter only instead of their intended/assigned IP address. Also keep in mind that IP binding still happens regardless of us assigning an IP or not, it just goes for whatever is the primary IP address on that machine. -
There's either something I am not getting or there is a bug connecting. If I had the time, I would totally try to figure out compiling Oxide / Oxide Rust and giving it a shot with that portion commented out, but I don't have the time to do that at the moment.
It seems pretty easy to test. Make any webrequest to localhost/127.0.0.1. Even if it's not able to connect you should see something like a connection failure instead of the "context" failure. And if it's not showing up anywhere else, then it's something on my end.
Just for complete clarity so the entire problem is in one post:
With the following code:
Code:webrequest.Enqueue("http://localhost:9090/", null, (code, response) => { Puts($"{code} {response}"); }, this, RequestMethod.GET, null, 100f);
Code:ConnectFailure (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
Code:ConnectFailure (The requested address is not valid in its context. )
-
Wulf Community Admin
-
Code:[PoundbotConnector] 0 Error: ConnectFailure (No connection could be made because the target machine actively refused it. ) No connection could be made because the target machine actively refused it.
-
Wulf Community Admin
-
-
Wulf Community Admin
-