Hi! I guess this was a step forward - but still not working...
I moved the parts to the OnStart method - it seems that only the OnStart is acting in elevated executionContext...
HttpListener MyHttpListener = null;
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
DiagnosticMonitor.Start("DiagnosticsConnectionString");
string port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["SMS_EP"].IPEndpoint.Port.ToString();
Trace.WriteLine("Initializing SMS Worker Role using port " + port + "...", "Information");
MyHttpListener = new HttpListener();
try
{
MyHttpListener.Prefixes.Add("http://*:" + port + "/");
MyHttpListener.Start();
Trace.WriteLine("Initializing using port " + port + " done", "Information");
}
catch (Exception ex)
{
Trace.Write("SMS Worker Role COULD NOT INITIALIZE! Error:" + ex.Message, "Error");
return false;
}
RoleEnvironment.Changing += RoleEnvironmentChanging;
return base.OnStart();
}
Still working in local enviroment ... and now also working (at lieast initializing correctly) in the cloud.
With RDP connection I did also check using netsh...
Now I see an entry like this (8404 is my used port)
Reserved URL :
http://10.119.148.5:8404/
User: CIS\f9ff2917-12d5-4e50-9ec2-59dd603e0076
Listen: Yes
Delegate: No
SDDL: D:(A;;GX;;;S-1-5-85-1709629745-3114573072-253485099-2827043508-603539684)
I also used a frre tool CurrPorts which shows:

This looks good, at least for me...
I've also wrote a small console application which just POSTs a XML document to the server. It's working when I post it to my local running instance.
But when I try to post it to http://myrole.cloudapp.net:8404
I'm just getting The remote server returned an error (503) Server Unavailiable.
But at least it's answering this request... posts to other ports times out...
Right after that netstat shows me a still pending connection:
TCP 10.119.148.5:8404 83-65-96-194:37232 TIME_WAIT
The 83-65-96-194 is my correct WAN-IP... and CurrPorts also shows:

For me it seems that there is still a conflict with some parts of the server side http handling...
One of my biggest issue for AZURE developing is, that I still didn't find way so see my Trace.Logs... (like I do in local compute emulator)
Any more ideas how to get closed to the problem?
Best Regards
Michael
"If we knew what it was we were doing - it would not be called research, would it?" -- A. Einstein