Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Netstat: Can not obtain ownership information
CydrickT
#1 Posted : Wednesday, May 28, 2014 3:24:45 PM(UTC)
Groups: Member
Joined: 5/28/2014(UTC)
Posts: 8
Location: Montreal

Thanks: 1 times
Hi,

First of all, I just want to say that UltiDev Web Server Pro is fantastic. We use it in our company and it fixed many problems we had with IIS.

I'm having a small problem with UltiDev Web Server Pro. In some cases, the web server is used on computers that are running Skype or Teamviewer. These two applications use the port 80, which means UltiDev cannot use the port 80 to display a website. I understand that you should not run any other application that uses the port 80 with UltiDev, but I would like to detect if another application got hold of the port 80, or if UltiDev Web Server got hold of it.

To detect which application got hold of the port 80, I can use the command "netstat -a -b" in a command prompt. If Skype or Teamviewer got hold of the port 80, it shows Skype.exe or Teamviewer.exe as the owner of that port. But if UltiDev Web Server got hold of the port, it says "Can not obtain ownership information".

Is there a way to make UltiDev Web Server display it's ownership of the port in netstat? Alternatively, is there any way to know if UltiDev Web Server got hold of the port without using netstat?

Thank you,

Cydrick
Ultidev Team
#2 Posted : Wednesday, May 28, 2014 9:19:34 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 59 time(s) in 58 post(s)
Hi, Cydrick.

Thank you much for the positive feedback. We're really happy when our little web server helps others.

Regarding netstats, UWS does not show up on the list because instead of opening TCP sockets in the process, it uses kernel-level http.sys driver - just like IIS 7.x. Http.sys is handling socket connections, which prevents all processes using http.sys from showing up on netstats. Using http.sys allows UWS share ports with other processes - you know how it's possible to share an http port between web applications as long as they specify different hostnames? UWS can do that just like IIS 7. In fact, same port can be shared by both IIS 7 and UWS. The problem begins when sockets are opened in exclusive modes in-process, which most programs do. Then such ports cannot be shared. UWS does not make any assumptions regarding port 80 being open and does not require it. UWS uses only port 7756 for its purposes.

When applications are registered, UWS highly recommends doing so in a way that does not assume any specific port the application should be put on. UWS provides redirector app on port 7756, which will redirect to your registered application by application ID, using the port application was registered on.

Please let us know if this information was helpful.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
CydrickT
#3 Posted : Thursday, May 29, 2014 10:33:25 AM(UTC)
Groups: Member
Joined: 5/28/2014(UTC)
Posts: 8
Location: Montreal

Thanks: 1 times
Hi,

Thanks for your quick reply. It is really appreciated.

We indeed use the http://*:0/ endpoint to let UltiDev decide which port to use. That is perfect for our needs. We also use virtual directories to display our pages. The problem we have is we want to know programmatically which ports UltiDev uses, and especially if UltiDev can use the port 80 to display pages.

In the worst case scenario, I will send a http request to a page on http://localhost:80/VirtualDirectory/ASpecificPage.aspx and verify if the page exists (meaning UltiDev can work on the port 80), but I am simply wondering if there's a better solution than this.

Thanks,
Cydrick
Ultidev Team
#4 Posted : Thursday, May 29, 2014 4:28:14 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 59 time(s) in 58 post(s)
Hi, Cydrick.

We think it may not possible to tell with 100% that a certain port is occupied by UWS, because if it's taken by IIS (http.sys to be more precise), it will look just as if it was taken by UWS.

It's pretty straightforward to get UWS application's addresses:
1. Get application information.
2. Get application desired addresses via ListenAddresses property.
3. Then for each address in the collection, call IsUrlFree(vDir) (with vDir value coming from the VirtualDirectory property of the object returned on step 1).

This will let you get to which ports/listen URLs UWS app was planning to listen, and which of them are occupied. It's just hard to tell whether they are occupied by UWS or someone else.

We wish we had a more bullet-proof solution for you, but we hope this may work.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
1 user thanked Ultidev Team for this useful post.
CydrickT on 5/29/2014(UTC)
CydrickT
#5 Posted : Friday, May 30, 2014 11:04:08 AM(UTC)
Groups: Member
Joined: 5/28/2014(UTC)
Posts: 8
Location: Montreal

Thanks: 1 times
Hi,

I understand the problem. I guess I will verify if the response code is 300 to check if UltiDev can display the page.

For anyone wondering what would be the code to do this in C#, here it is:


public static bool IsWebsiteUnderOurControl(int targetPort)
{

var virtualFolder = "VirtualFolder/" //TODO Change
var request = (HttpWebRequest)WebRequest.Create("http://localhost:" + targetPort + "/" + virtualFolder);
request.Method = "HEAD";

var statusCode = HttpStatusCode.NoContent;

//If UltiDev cannot get that port, this is where it is gonna crash.
try
{
Task task = Task.Factory.StartNew(
() =>
{
try
{
statusCode = ((HttpWebResponse)request.GetResponse()).StatusCode;
}
catch (Exception)
{}
});
task.Wait(1000); //We wait 1 second max
return task.IsCompleted;
}
catch (Exception)
{ }

return statusCode == HttpStatusCode.OK;
}


Thanks for your help,
Cydrick
Ultidev Team
#6 Posted : Sunday, June 1, 2014 10:21:46 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 59 time(s) in 58 post(s)
Hi, Cydrick.

If your application that is registered with UWS is a redistributable software, then your AppID should be well-known to you and you should keep it the same even as you release new versions of it. If you are registering applications manually, using UltiDev Web Server Explorer, then let us know - doing what you are asking will require using undocumented members of UWS Configuration API. We'll put together a quick guide how to do that.

Maybe if you outline your larger use case, we may come up with a better solution recommendation for you.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
CydrickT
#7 Posted : Monday, June 2, 2014 7:49:22 AM(UTC)
Groups: Member
Joined: 5/28/2014(UTC)
Posts: 8
Location: Montreal

Thanks: 1 times
Hi,

As stated in my previous post, I will use another way to detect if the website is accessible. I tried the solution you proposed and then understood what you meant by "This will let you get to which ports/listen URLs UWS app was planning to listen, and which of them are occupied."

I also gave a solution to verify if the website is accessible in my previous post. This solution (in C#) actually verifies if the website is accessible at a specified port

Thanks for your help. It is really appreciated,
Cydrick

Ultidev Team
#8 Posted : Monday, June 2, 2014 7:52:01 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 59 time(s) in 58 post(s)
Sounds good!

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Rss Feed  Atom Feed
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.