Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > java socket write error -> talking with asp.net

Reply
Thread Tools

java socket write error -> talking with asp.net

 
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      11-03-2005
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?
 
Reply With Quote
 
 
 
 
Bruce Barker
Guest
Posts: n/a
 
      11-03-2005
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:0461A60C-8C3A-4DF8-80A2-...
> 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?



 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      11-03-2005
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:0461A60C-8C3A-4DF8-80A2-...
> > 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?

>
>
>

 
Reply With Quote
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      11-03-2005
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.
 
Reply With Quote
 
mensikd@gmail.com
Guest
Posts: n/a
 
      11-09-2005
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.

 
Reply With Quote
 
mensikd@gmail.com
Guest
Posts: n/a
 
      11-09-2005
And turn off tracing.
In web.config :
<trace
enabled="false"... >

Ozon

 
Reply With Quote
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      11-09-2005
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
>
>

 
Reply With Quote
 
mdinant mdinant is offline
Junior Member
Join Date: Apr 2008
Location: amsterdam
Posts: 2
 
      04-04-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[META] Talking about talking about C. Seebs C Programming 113 11-24-2010 08:57 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM
Talking to C++ sever using Java socket Ranjit Java 8 04-21-2005 09:31 PM



Advertisments