httpListener, AsyncCallback syntax

This forum is meant for examples of X# code.

User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

httpListener, AsyncCallback syntax

Post by Horst »

Hallo Wolfgang
Remember, i let run your listener as a task and every houre it stops, now i tryed to let it run with your service example as windows service. But also the service it stops sometimes. i have 2 Internet Server. On the newer one (MS Server 2019) its working without stop on the old one (MS Server 2008 R2) it stops. Now after 2h, i found a error message from the .Net Runtime

Anwendung: xsharpservice.exe
Frameworkversion: v4.0.30319
Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet.
Ausnahmeinformationen: System.Net.HttpListenerException
bei System.Net.HttpResponseStream.Write(Byte[], Int32, Int32)
bei XsHttpListener.MainProgram.GetContextCallback(System.IAsyncResult)
bei System.Net.LazyAsyncResult.Complete(IntPtr)
bei System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
bei System.Net.ListenerAsyncResult.IOCompleted(System.Net.ListenerAsyncResult, UInt32, UInt32)
bei System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

and then: source Applikation Error

Name der fehlerhaften Anwendung: xsharpservice.exe, Version: 0.0.0.0, Zeitstempel: 0x5e4d0f0f
Name des fehlerhaften Moduls: KERNELBASE.dll, Version: 6.1.7601.24545, Zeitstempel: 0x5e0eb6bd
Ausnahmecode: 0xe0434352
Fehleroffset: 0x000000000000b87d
ID des fehlerhaften Prozesses: 0x6d0
Startzeit der fehlerhaften Anwendung: 0x01d5e79ad53deb84
Pfad der fehlerhaften Anwendung: d:webhorst.korakunvalid.chxsharpservice.exe
Pfad des fehlerhaften Moduls: C:Windowssystem32KERNELBASE.dll
Berichtskennung: 1b374672-53ba-11ea-ab6e-00155dcefc02


Can u help me ? I have no idea whats that.
Horst
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

httpListener, AsyncCallback syntax

Post by Horst »

Hi
And i try to translate this c# into x# but wtf is listener.prefixes ? its used like a array but its not.
i tryed
FOREACH prefix AS STRING IN _oListener:Prefixes
oSB:AppendFormat( e"Prefixes: {0} = {1}n", prefix) //, _oListener:Prefixes [prefix] )
NEXT

But the Service crashed. Btw it comes the same errormessage from .Net Runtime like the services is doing that sometimes without this part of code.

public static void DisplayPrefixesAndState(HttpListener listener)
{
// List the prefixes to which the server listens.
HttpListenerPrefixCollection prefixes = listener.Prefixes;
foreach(string prefix in prefixes)
{
Console.WriteLine(prefix);
}
User avatar
SHirsch
Posts: 282
Joined: Tue Jan 30, 2018 8:23 am

httpListener, AsyncCallback syntax

Post by SHirsch »

Hello Horst,

you tried to access _oListener:Prefixes like a dictionary. But it seems to be just like a list of strings.
This should be the correct way (see {1} has no corresponding parameter in your version):

Code: Select all

FOREACH prefix AS STRING IN _oListener:Prefixes
oSB:AppendFormat( e"Prefixes: {0}n", prefix)
NEXT
Stefan
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

httpListener, AsyncCallback syntax

Post by Horst »

Hi Stefan
Thanks that works :-)
My fault , i did not analys what this AppendFormat is realy doing.

Thanks
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

httpListener, AsyncCallback syntax

Post by wriedmann »

Hi Horst,
sorry for not having answered, but I was really busy as a new project is in production now.
It is a production planning software, written entirely in X# and accessing data on DBFs, Oracle and PostgreSQL databases.
But I have seen that others have helped you in the meantime - and this is the bonus of a public forum.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
kitz
Posts: 87
Joined: Wed Nov 29, 2017 8:56 am

httpListener, AsyncCallback syntax

Post by kitz »

Hello Wolfgang,
I have a HttpListener in place and working, had nearly never problems in Win7 for wears. Recently I had to move to Win10, same program.
Now sometimes the sender (from outside, but in company network) gets a timeout, because my listener program just stops working after a request. I don't get any error messages in my try catch blocks neither in the functions nor in the main program.
Do you have any tip what to do to get an error message or any other hint what is going on?
BR Kurt
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

httpListener, AsyncCallback syntax

Post by wriedmann »

Hi Kurt,
unfortunately I have no idea. My only production of the httpListener is running on a Windows Server 2012 R2 (it is the server version of Windows 7, now both out of maintenance).

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

httpListener, AsyncCallback syntax

Post by Horst »

Hallo Kurt
i used the listerner from Woffgang and every some hours it stops. Because it was only handling Get and Post, comes a HEAD request the listerner crashed. Maybe it helps.
Horst
kitz
Posts: 87
Joined: Wed Nov 29, 2017 8:56 am

httpListener, AsyncCallback syntax

Post by kitz »

Hello Horst,
thanks for the suggestion, but I know that I only get POST requests and I know the sender.
I am testing now, if a request is finished synchronally instead of asynchronally because in that case my program would stop. Some years ago I created it, so not all details are present in my brain. Now on new computer, new OS and SSD disk it maybe fast enough…
BR Kurt
User avatar
Horst
Posts: 327
Joined: Tue Oct 13, 2015 3:27 pm

httpListener, AsyncCallback syntax

Post by Horst »

Hello

Wolfgang wrote:
My only production of the httpListener is running on a Windows Server 2012 R2 (it is the server version of Windows 7, now both out of maintenance).
if have a question, my httplistener is also runing on a window server and also the iis is running. i tried to uninstall the iis because i dont need this overhead but then the httplisterner is not working. what is missing when i uninstall the iis ? any idea ?

Horst
Post Reply