HttpListenerException when trying to listen to non-localhost target
I am trying to listen to a certain endpoint, using the following code:
string url = "http://111.111.1.11:8080/";
HttpListener listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
listener.Start() throws HttpListenerException: 'The format of the specified network name is invalid'
Researching the problem I tried the following solutions with no luck:
- Disabling firewall entirely
- Adding the url to listen list, and to urlacl using netsh http add commands (both of them)
Worth mentioning that the listener does work when i change the url to localhost.
Could there be some kind of constraints I am not aware of in my network?
Appreciate any help!
c# http listener httplistener
|
show 3 more comments
I am trying to listen to a certain endpoint, using the following code:
string url = "http://111.111.1.11:8080/";
HttpListener listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
listener.Start() throws HttpListenerException: 'The format of the specified network name is invalid'
Researching the problem I tried the following solutions with no luck:
- Disabling firewall entirely
- Adding the url to listen list, and to urlacl using netsh http add commands (both of them)
Worth mentioning that the listener does work when i change the url to localhost.
Could there be some kind of constraints I am not aware of in my network?
Appreciate any help!
c# http listener httplistener
1
Is that IP address present on your machine? IE does it show up when you run ipconfig?
– David Browne - Microsoft
Nov 12 '18 at 15:30
@DavidBrowne-Microsoft yes, it's a different IP in my solution that responds to pings and shows up in browsers
– oren k
Nov 12 '18 at 15:32
But is it an IP on the machine where you're running that code?
– David Browne - Microsoft
Nov 12 '18 at 15:37
@DavidBrowne-Microsoft it's an IP of a PC in my LAN
– oren k
Nov 12 '18 at 15:51
1
Then you're using the wrong type. HttpListener is for listening to incoming HTTP requests on one (or all) of your local IPs. You can't listen on another PC's IP address. You can use WebClient to send request to an HTTP Listener running on that PC. docs.microsoft.com/en-us/dotnet/api/…
– David Browne - Microsoft
Nov 12 '18 at 15:53
|
show 3 more comments
I am trying to listen to a certain endpoint, using the following code:
string url = "http://111.111.1.11:8080/";
HttpListener listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
listener.Start() throws HttpListenerException: 'The format of the specified network name is invalid'
Researching the problem I tried the following solutions with no luck:
- Disabling firewall entirely
- Adding the url to listen list, and to urlacl using netsh http add commands (both of them)
Worth mentioning that the listener does work when i change the url to localhost.
Could there be some kind of constraints I am not aware of in my network?
Appreciate any help!
c# http listener httplistener
I am trying to listen to a certain endpoint, using the following code:
string url = "http://111.111.1.11:8080/";
HttpListener listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
listener.Start() throws HttpListenerException: 'The format of the specified network name is invalid'
Researching the problem I tried the following solutions with no luck:
- Disabling firewall entirely
- Adding the url to listen list, and to urlacl using netsh http add commands (both of them)
Worth mentioning that the listener does work when i change the url to localhost.
Could there be some kind of constraints I am not aware of in my network?
Appreciate any help!
c# http listener httplistener
c# http listener httplistener
asked Nov 12 '18 at 15:22
oren koren k
83
83
1
Is that IP address present on your machine? IE does it show up when you run ipconfig?
– David Browne - Microsoft
Nov 12 '18 at 15:30
@DavidBrowne-Microsoft yes, it's a different IP in my solution that responds to pings and shows up in browsers
– oren k
Nov 12 '18 at 15:32
But is it an IP on the machine where you're running that code?
– David Browne - Microsoft
Nov 12 '18 at 15:37
@DavidBrowne-Microsoft it's an IP of a PC in my LAN
– oren k
Nov 12 '18 at 15:51
1
Then you're using the wrong type. HttpListener is for listening to incoming HTTP requests on one (or all) of your local IPs. You can't listen on another PC's IP address. You can use WebClient to send request to an HTTP Listener running on that PC. docs.microsoft.com/en-us/dotnet/api/…
– David Browne - Microsoft
Nov 12 '18 at 15:53
|
show 3 more comments
1
Is that IP address present on your machine? IE does it show up when you run ipconfig?
– David Browne - Microsoft
Nov 12 '18 at 15:30
@DavidBrowne-Microsoft yes, it's a different IP in my solution that responds to pings and shows up in browsers
– oren k
Nov 12 '18 at 15:32
But is it an IP on the machine where you're running that code?
– David Browne - Microsoft
Nov 12 '18 at 15:37
@DavidBrowne-Microsoft it's an IP of a PC in my LAN
– oren k
Nov 12 '18 at 15:51
1
Then you're using the wrong type. HttpListener is for listening to incoming HTTP requests on one (or all) of your local IPs. You can't listen on another PC's IP address. You can use WebClient to send request to an HTTP Listener running on that PC. docs.microsoft.com/en-us/dotnet/api/…
– David Browne - Microsoft
Nov 12 '18 at 15:53
1
1
Is that IP address present on your machine? IE does it show up when you run ipconfig?
– David Browne - Microsoft
Nov 12 '18 at 15:30
Is that IP address present on your machine? IE does it show up when you run ipconfig?
– David Browne - Microsoft
Nov 12 '18 at 15:30
@DavidBrowne-Microsoft yes, it's a different IP in my solution that responds to pings and shows up in browsers
– oren k
Nov 12 '18 at 15:32
@DavidBrowne-Microsoft yes, it's a different IP in my solution that responds to pings and shows up in browsers
– oren k
Nov 12 '18 at 15:32
But is it an IP on the machine where you're running that code?
– David Browne - Microsoft
Nov 12 '18 at 15:37
But is it an IP on the machine where you're running that code?
– David Browne - Microsoft
Nov 12 '18 at 15:37
@DavidBrowne-Microsoft it's an IP of a PC in my LAN
– oren k
Nov 12 '18 at 15:51
@DavidBrowne-Microsoft it's an IP of a PC in my LAN
– oren k
Nov 12 '18 at 15:51
1
1
Then you're using the wrong type. HttpListener is for listening to incoming HTTP requests on one (or all) of your local IPs. You can't listen on another PC's IP address. You can use WebClient to send request to an HTTP Listener running on that PC. docs.microsoft.com/en-us/dotnet/api/…
– David Browne - Microsoft
Nov 12 '18 at 15:53
Then you're using the wrong type. HttpListener is for listening to incoming HTTP requests on one (or all) of your local IPs. You can't listen on another PC's IP address. You can use WebClient to send request to an HTTP Listener running on that PC. docs.microsoft.com/en-us/dotnet/api/…
– David Browne - Microsoft
Nov 12 '18 at 15:53
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265191%2fhttplistenerexception-when-trying-to-listen-to-non-localhost-target%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265191%2fhttplistenerexception-when-trying-to-listen-to-non-localhost-target%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Is that IP address present on your machine? IE does it show up when you run ipconfig?
– David Browne - Microsoft
Nov 12 '18 at 15:30
@DavidBrowne-Microsoft yes, it's a different IP in my solution that responds to pings and shows up in browsers
– oren k
Nov 12 '18 at 15:32
But is it an IP on the machine where you're running that code?
– David Browne - Microsoft
Nov 12 '18 at 15:37
@DavidBrowne-Microsoft it's an IP of a PC in my LAN
– oren k
Nov 12 '18 at 15:51
1
Then you're using the wrong type. HttpListener is for listening to incoming HTTP requests on one (or all) of your local IPs. You can't listen on another PC's IP address. You can use WebClient to send request to an HTTP Listener running on that PC. docs.microsoft.com/en-us/dotnet/api/…
– David Browne - Microsoft
Nov 12 '18 at 15:53