java socket write error -> talking with asp.net

Discussion in 'ASP .Net' started by =?Utf-8?B?SmFzb24gQ2h1?=, Nov 3, 2005.

  1. situation:
    I'm uploading file to my application using a java applet sending the request
    (the file) through socket to my asp.net page.
    On my asp.net page, I've override the httpmodule to take in the request and
    saves the file to disk (on the server).
    My .net side works if I use a simple html file input and post it, I've read
    in the uploaded request (multipart form), and reproduced it in the java
    applet.
    Everything works fine when I upload a file around 20kb, but anything bigger,
    I get that socket write error on the java side.

    Now from the .net side the request.ReadEntityBody(data, bufferSize); will
    return 0, meaning it's not reading anything from the request, and on the java
    side I get the socket error.

    So, who's causing the connection abort? .NET? IIS? XP?

    I've put in the <httpRuntime executionTimeout="1800"
    maxRequestLength="524288" /> in web.config, so timeout shouldn't be the
    problem, as the whole upload process will last less than a second before it
    dies.

    Any suggestions?
    =?Utf-8?B?SmFzb24gQ2h1?=, Nov 3, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?SmFzb24gQ2h1?=

    Bruce Barker Guest

    you have to write the code for ReadEntityBody. the default implementation
    just returns a zero. if your handler want to call this routine, it should
    override it and supply the code.

    -- bruce (sqlwork.com)



    "Jason Chu" <> wrote in message
    news:...
    > situation:
    > I'm uploading file to my application using a java applet sending the
    > request
    > (the file) through socket to my asp.net page.
    > On my asp.net page, I've override the httpmodule to take in the request
    > and
    > saves the file to disk (on the server).
    > My .net side works if I use a simple html file input and post it, I've
    > read
    > in the uploaded request (multipart form), and reproduced it in the java
    > applet.
    > Everything works fine when I upload a file around 20kb, but anything
    > bigger,
    > I get that socket write error on the java side.
    >
    > Now from the .net side the request.ReadEntityBody(data, bufferSize); will
    > return 0, meaning it's not reading anything from the request, and on the
    > java
    > side I get the socket error.
    >
    > So, who's causing the connection abort? .NET? IIS? XP?
    >
    > I've put in the <httpRuntime executionTimeout="1800"
    > maxRequestLength="524288" /> in web.config, so timeout shouldn't be the
    > problem, as the whole upload process will last less than a second before
    > it
    > dies.
    >
    > Any suggestions?
    Bruce Barker, Nov 3, 2005
    #2
    1. Advertising

  3. yea...but it's returning 0 because there is no more to read...since the
    socket connection has been aborted somehow.
    other than that the readentitybody is functioning as it should.

    I need to find out why the connection is aborted.

    On a update note, I find that on a fresh new aspnet process, the upload goes
    further, and following uploads will end at most at 48kb.
    Then after I kill the aspnet process and upload again, it'll go beyond 48kb
    again.


    "Bruce Barker" wrote:

    > you have to write the code for ReadEntityBody. the default implementation
    > just returns a zero. if your handler want to call this routine, it should
    > override it and supply the code.
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    > "Jason Chu" <> wrote in message
    > news:...
    > > situation:
    > > I'm uploading file to my application using a java applet sending the
    > > request
    > > (the file) through socket to my asp.net page.
    > > On my asp.net page, I've override the httpmodule to take in the request
    > > and
    > > saves the file to disk (on the server).
    > > My .net side works if I use a simple html file input and post it, I've
    > > read
    > > in the uploaded request (multipart form), and reproduced it in the java
    > > applet.
    > > Everything works fine when I upload a file around 20kb, but anything
    > > bigger,
    > > I get that socket write error on the java side.
    > >
    > > Now from the .net side the request.ReadEntityBody(data, bufferSize); will
    > > return 0, meaning it's not reading anything from the request, and on the
    > > java
    > > side I get the socket error.
    > >
    > > So, who's causing the connection abort? .NET? IIS? XP?
    > >
    > > I've put in the <httpRuntime executionTimeout="1800"
    > > maxRequestLength="524288" /> in web.config, so timeout shouldn't be the
    > > problem, as the whole upload process will last less than a second before
    > > it
    > > dies.
    > >
    > > Any suggestions?

    >
    >
    >
    =?Utf-8?B?SmFzb24gQ2h1?=, Nov 3, 2005
    #3
  4. Update:
    I've solve the problem on the java part now.

    Problem now is with .NET's readentitybody returning 0 bytes read, even if
    there's more things to be read.
    I'm posting this on a new question, as the topic's changing.
    =?Utf-8?B?SmFzb24gQ2h1?=, Nov 3, 2005
    #4
  5. =?Utf-8?B?SmFzb24gQ2h1?=

    Guest

    Re: java socket write error -> talking with asp.net (ReadEntityBody, block, problem)

    Hi,
    In loop where you are reading data:

    while(ms.Position < req.ContentLength)
    {
    bytesRead = worker.ReadEntityBody(buffer, buffer.Length);
    ms.Write(buffer, 0, bytesRead);
    }

    realloate buffer for last reading. I've discovered that if you have
    last e.g. 58 B for read in request, and you are reading to buffer
    allocated to 100 B with code:

    bytesRead = worker.ReadEntityBody(buffer, buffer.Length);

    then (IMHO!!!!) system will wait for buffer.Length Bytes. So I
    reallocate the buffer to the last of request data and everything goes
    well - except of two days of lost time and de-ja vu, because I've
    already solved this problem, but forget the solution very quickly... :(

    Solution is in code below.

    while(ms.Position < req.ContentLength)
    {
    bytesRead = worker.ReadEntityBody(buffer, buffer.Length);
    ms.Write(buffer, 0, bytesRead);

    newBufferSize = req.ContentLength - (int)ms.Position;
    if(newBufferSize < BUFFER_SIZE && newBufferSize > 0)
    buffer = new byte[req.ContentLength - ms.Position];
    }

    With best regard,
    Ozon.
    , Nov 9, 2005
    #5
  6. =?Utf-8?B?SmFzb24gQ2h1?=

    Guest

    Re: java socket write error -> talking with asp.net (ReadEntityBody, block, problem)

    And turn off tracing.
    In web.config :
    <trace
    enabled="false"... >

    Ozon
    , Nov 9, 2005
    #6
  7. Re: java socket write error -> talking with asp.net (ReadEntityBod

    That's interesting...I found a solution...but couldn't explain it...
    it has to do with my java side uploading the file...
    right at the end of sending out the file section....before I write teh
    footer to the file section of the multiform...I put in a delay....of
    100ms.....
    and magically....everything goes...
    it would be nice if you can explain why that works for me.
    I discovered this when I trace through my java code...and find that tracing
    through the java works....but not if I run it normally...


    "" wrote:

    > And turn off tracing.
    > In web.config :
    > <trace
    > enabled="false"... >
    >
    > Ozon
    >
    >
    =?Utf-8?B?SmFzb24gQ2h1?=, Nov 9, 2005
    #7
  8. =?Utf-8?B?SmFzb24gQ2h1?=

    mdinant

    Joined:
    Apr 4, 2008
    Messages:
    1
    Location:
    amsterdam
    Interested in ASP.NET/Java

    Hi there, I am new to this forum. I want to write a server application on ASP.NET, and write client code with Java. I was wandering if you could give me something to start with, or some tips/ideas.

    Eventually I want to use the UDP protocol, because I am making real time games.
    My webhosting wont install Apache, (they apologized)

    I've read that it is/was possible to write a servlet on ASP.NET, but I just saw that microsoft doesnt do java anymore, so thats no option, (i think...)

    Thanks for your time, Matthijs Dinant
    mdinant, Apr 4, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ranjit
    Replies:
    8
    Views:
    2,819
    Betty
    Apr 21, 2005
  2. Laszlo Nagy
    Replies:
    1
    Views:
    4,754
    Mark Wooding
    Jan 27, 2009
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    942
    Jean-Paul Calderone
    Jan 27, 2009
  4. Laszlo Nagy
    Replies:
    0
    Views:
    524
    Laszlo Nagy
    Feb 1, 2009
  5. Seebs

    [META] Talking about talking about C.

    Seebs, Oct 23, 2010, in forum: C Programming
    Replies:
    113
    Views:
    2,211
    Tim Rentsch
    Nov 24, 2010
Loading...

Share This Page