c# - Exception-proof HttpListener possible? -


last few days i've been building web server application in c# uses httplistener. i've learned quite lot on way, , still am. got working, setting headers here , there depending on situations.

in cases things working fine, @ times exception error thrown. happens on few occasions. if not of them closing connection before data send. error occurs. of them caused browsers far can tell.

like let's take chrome. whenever go mp3 file directly, sends 2 requests. , 1 of them causing error, other working , receiving part of content. after this, can listen mp3 , there no issues. streaming works. request gives me error, there nothing in headers use in code not output data, head requests. i'm quite puzzled here.

ie has problem both opening mp3 files directly, , streaming via html5 audio tag. varies time time. open page, , 2 requests made. html page, , mp3. no error there. tho, there 3 requests. connects mp3 twice. 1 of connections being aborted straight after open page, , 2 requests mp3 file, doesn't accept data. in both request headers, want end of file. bytes: 123-123/124. i've tested on w3school's audio element. ie makes twice connections there, 1 aborted, other loading mp3 file.

so question is, possible make web server exception/error-proof, or maybe better question, bad these exceptions thrown? or perhaps know how fix these errors?

the error i'm getting is: i/o operation has been aborted either thread exit or application request.

the way write client is:

            using (stream output = _cresponse.outputstream)             {                 output.write(_fileoutput, rangebegin, rangelength);             } 

i not sure if there's (better) way. came across in many topics, tutorials , pages while researching.

about headers: default headers: content length, content type, status code. in cases, mp3 files , video's, add accept-ranges: bytes header. in case request header has range in it, add content-range header, , partialcontent status code.

from server's point of view client can disconnect @ time. part of normal operation of server. detect specific case, log , swallow exception (because has been handled). it's not server bug.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -