Networking :: Intermittent Socket Closed Exception

Jun 24, 2014

We have a servlet application running under jboss 7.1.1/java 1.7 that sends http requests to another server. Everything works fine for most of the time, but occasionally (from one to a couple of times a day) we get a “Socket closed” exception.  I’ve been trying to find out what might be causing this but so far I’ve been unsuccessful. By the way, this has been happening while the application was running under older versions of Jboss/Java so the version might not be that relevant.

Here’s an excerpt from the method where this happens:
. . . . .
try
{
HttpURLConnection conn = (HttpURLConnection) urlEndpoint.openConnection();
   conn.setRequestMethod("POST");
   conn.setDoInput(true);
   conn.setDoOutput(true);

[Code] ....

And here’s what the exception looks like:
. . . . . .
java.net.SocketException: socket closed               
at java.net.SocketInputStream.socketRead0(Native Method)
                at java.net.SocketInputStream.read(SocketInputStream.java:150)
                at java.net.SocketInputStream.read(SocketInputStream.java:121)
                at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)

[Code] ....           
 
In my investigation I  came across some posts that were mentioning the sockets pool the http connection is keeping, but I’m not sure whether and how this solve the problem I have.

View Replies


ADVERTISEMENT

Socket Closed Exception Being Thrown

Feb 10, 2014

I have been working with socket programming. I was trying to develop a two way communication from server to client. The data is being received when sent from server to client but there is a problem when I am sending from client to server.

I am getting an error as "Socket is closed" pointing to the line where I have created a BufferedReader. I have simplified some part of my code to be very specific.

Code attached.

import java.io.*;
import java.net.*;
import java.util.*;
public class Server
{
public static void main(String args[])
{
String id="policeone";
int hashcodeid=0;

[Code] ....

Error::

Receiving string from client: 'java.net.SocketException: Socket is closed
at java.net.Socket.getInputStream(Socket.java:872)
at Server.main(Server.java:51)

View Replies View Related

Networking :: Socket Creation Too Slow Versus URLConnection

Oct 27, 2014

I'm trying to write a transparent proxy like polipo. Polipo is written in C and I want to have the same result in java.
 
A simple program that can filter/monitor all connections created and closed by the browser.
 
To do so, I've chosen to work with sockets, because that's the only way i know to read and write raw data to and from the browser in a completely transparent way.
 
In this moment my code reads and writes every couple of request/response but I've noticed profiling it that the time needed to create the socket is a bottleneck.

Using URLConnection to create the same connection I need much less time than sockets.
 
When socket creation implies 50ms URLConnection implies only 1ms.

View Replies View Related

Networking :: Error While Sending Files Between Two Systems Using Socket

Mar 11, 2014

I've been trying to send a file(text & image files) from one system to another. somewhat I did, but file is not send originally in destination system. It shows AccessDeniedException on the destination system. What should do to avoid this exception.

View Replies View Related

Networking :: Getting Exception While Trying To Remotely Call One Servlet - URL Connect

Oct 14, 2014

I am trying to remotely call one servlet and getting below exception:
 
java.io.StreamCorruptedException: invalid stream header: 3C21444F
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:785)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:282)
at com.deere.isg.dm.web.controller.StatsController.getOtherAdminStatsBeanFromConnectURL2(StatsController.java:224)
at com.deere.isg.dm.web.controller.StatsController.main(StatsController.java:122)
 
As per my program i am just simply calling this:
 
URL url = new URL(controllerPath + STATS_PATH);
 
  httpURLConnection = (HttpURLConnection)url.openConnection();
  httpURLConnection.setRequestMethod("GET");
  httpURLConnection.connect();
 
  inputStream = httpURLConnection.getInputStream();
  objectInputStream = new ObjectInputStream(inputStream);

View Replies View Related

Socket Exception - Connection Reset

May 13, 2014

I got the below exception .how to resolve this .It's receiving the data up to 10 min then suddenly below error happening. I have embedded the source code below

java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)

[Code] .....

View Replies View Related

Servlets :: Intermittent Loss Of Some Session Attributes

May 21, 2014

Session attributes after logging into web-app:

Session Attributes
thisUsersAllowedRoles=45
username=hw
authenticatedUser=org.hw.client.payroll.model.User@2c8a09da
supervisorCode=
authenticated=true

[Code] ....

Every now and then while debugging I lose session attributes:

Session Attributes
thisUsersAllowedRoles=45
username=hw
supervisorCode=
authenticated=true

[Code] ....

The authenticatedUser and menu attributes are gone. I never know when it's going to happen so I can't trace it. Any guesses why those type session objects would die?

I attached an image of what menu object looks like.

View Replies View Related

Adding Another Statement - ResultSet Is Closed

Aug 15, 2014

I'm want to call another statement within the same resultSet. But it gives an error that the result set is closed.

public static void updateAlarmStatus(int status) {
ResultSet rs = null;
database.restartDatabase();
try {
rs = database
.executeQuery("Select alarmId from alarms where alarmDate = '"

[Code] ....

I googled it and came to know that resultSet is automatically closed if we call another statement within in. I've also tried creating the connection again before the second statement but of no use.

View Replies View Related

Closed Opened Up Input File

Mar 19, 2014

I have opened up an input file using

File input=new File("hello.txt")..

Then I have created a scanner object that reads data from the file.

Scanner read_file=new Scanner (input).

my question is when closing the files why can't I just do input.close() since that is also closing the file?

View Replies View Related

String Literal Is Not Properly Closed By Double Quote

Apr 28, 2014

I am working with java project which is kind of charting room..but the problem is when am writing the query for listing the message in the conversation the error prevail in my eclipse...string literal is not properly closed by double quote...this is my java file

<%
String uname=session.getAttribute("username").toString();
String pword=session.getAttribute("password").toString();
java.util.Date dat=new Date();
int x=1;
try{

[code]....

View Replies View Related

String Literal Is Not Properly Closed By A Double Quote

Jul 11, 2014

string literal is not properly closed by a double quote

View Replies View Related

Existing Connection Was Forcibly Closed By Remote Host Linux

Aug 14, 2014

I have a Linux Server Debian 7 x86_64 Minimal With java version "1.7.0_65" installed..Its an online Game Server wich Players can join just like other Services.Every 10 - 15 minutes all the players get kicked from the server and get this messege: "internal exception: java.io.ioexception: an existing connection was forcibly closed by remote host"

The players can't join the server for 10 seconds and the server console doesn't show anything for 10 seconds.it doesnt show that the players even left! and when the players try to join they get htis messege: "same nick is already playing"

After 10 seconds everything will work and players can join again and server console say that everyone left and joined..But that happens again after 10 minutes and im losing lots of players because of this error.

View Replies View Related

Scanner Closed - Import Via Keyboard Numbers And Calculate Mean And Standard Deviation To Results

Oct 24, 2014

The purpose of this program is to import via keyboard Numbers.txt and calculate the mean and standard deviation to Results.txt.I am able to get the mean calculate but when I open the Results.txt the standard deviation is 0. I don't know what is wrong with my code, but I believe it has something to do with the scanner being close. Here is the error message i receive after inputting Numbers.txt.

java.lang.IllegalStateException: Scanner closed
at java.util.Scanner.ensureOpen(Unknown Source)
at java.util.Scanner.hasNext(Unknown Source)
at StatsDemo.main(StatsDemo.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272)

Java Code:

import java.text.DecimalFormat; //for number formatting
import java.util.Scanner; //for keyboard input
import java.io.*; //for using files
public class StatsDemo
{
public static void main(String [] args) throws IOException

[Code] .....

View Replies View Related

Networking Flow Of Control

Sep 2, 2014

So I'm working on some networking code and I have the Server running as its own thread, then I have a PacketListener which is contained in the Server, that is running on its own thread too. As of right now, the PacketListener waits for packets via DatagramSocket.receive() and then adds them to a queue. The Server runs in a loop and it checks that queue for packets and then polls the most recent and process it before sleeping for 1 millisecond. Here is my question though, I'm considering changing the program to a more observer pattern structure in that when the PacketListener would receive a packet, rather than add it to the queue, it'd notify the server which would process it. However, wouldn't this cause additional time required within the PacketListener thread dedicated to processing the packets rather than listening for them?

View Replies View Related

Networking :: No Websocket Support For Swing

Jun 18, 2015

When a JavaScript client attempts to open a socket, instead of the connection opening it immediately closes. The client is using:
 
webSocket = new WebSocket("ws://localhost/example");
 
The same thing happens for com.sun.net.httpserver.HttpsServer where client is using:
 
webSocket = new WebSocket("wss://localhost/example");
 
How can I enable websocket support?
 
If it's not possible, how can I request for it to be added as a new feature?

View Replies View Related

Networking :: Get Timestamp Of A File On Server

Aug 6, 2014

I have a requirement to get the details of the files present in a directory on a server. I need to get the file names and timestamp. I have the below code to get the file names:

Connection conn = new OracleDriver().defaultConnection();
ArrayDescriptor arraydesc =
ArrayDescriptor.createDescriptor ("DIRLIST_T", conn);
File myDir = new File (dir);
String[] filesList = myDir.list();
ARRAY dirArray = new ARRAY(arraydesc, conn, filesList);
return dirArray;
 
But am not able to get the timestamp. How can I get the timestamp as well.

View Replies View Related

Networking :: Limiting Bandwidth Usage?

Mar 18, 2015

I would like to limit my bandwidth usage when accessing/downloading files (similar to the --limit-rate 50K option for curl and wget) as the website has limited bandwidth. I am not exactly sure how to implement this, but I'm guessing it be accomplished via the BufferedReader? I have attached the current code below.
 
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;

[Code]....

View Replies View Related

Networking :: URL Connection Error On HTTPs

Feb 16, 2013

I have noticed an error, that makes sometimes troubles, when downloading jars from https addresses, when there are many jars to download..

Best example is by opening Javas on Java version checker. [URL] ....

I get also following log...

network: Connecting https://www.java.com/jsp_utils/jreverification.jar with proxy=DIRECT
network: Connecting http://www.java.com:443/ with proxy=DIRECT
network: Connecting https://www.java.com/jsp_utils/jreverification.jar with cookie "JSESSIONID=22ABBA2BE9B5789629C276AC35BDF969; s_cc=true;

Even if the address is https, java try to access via http protocol on port 443, and that leads sometimes to problems..

I have noticed this, when I have used URLConnection(HttpURLConnection) for my self, as soon Java sends http link on https address, the jar gets sometimes not loaded, and i get error about missing class that get called..

On http addres it is not so bad, since same protocol is used, but evidently, that is evil for https..

As you see, that happens already when loading Jar by Applet Starter and at all, it happens each time on any URLConnection

###############################
Java Plug-in 10.13.2.20
Using JRE version 1.7.0_13-b20 Java HotSpot(TM) Client VM
User home directory = X:Usersadmin
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect

[Code] .....

View Replies View Related

Networking :: SocketChannel Hangs Up After Several Read (ByteBuffer)

Nov 9, 2013

I wrote a proxy in java. The version with ServerSocket-Socket/Stream-IO works wonderfully. When I rewrote it to ServerSocketChannel-SocketChannel/ByteBuffer it works also very well. However, when I access YouTube things happen weirdly: The video is frozen after 3 or 5 minutes (but this did not with the version of ServerSocket/Socket). I strongly assume that there probably was a nasty bug....  The (shortened) codes are:

Server:
        public class BeanServer extends Thread {
             public BeanServer( ) { }
          public void run( ) {
               try {
                    bServer = ServerSocketChannel.open();

[Code] .....

View Replies View Related

Networking :: Ethernet Works Fine But Not Wireless

Jan 30, 2014

My application with Oracle Database only works with Ethernet, I tried to connect via wireless without any response. When I run the command netstat the port state is WAIT TIME and then be closing. The clients machines run Windows 7 and 8 and the server run Suse Linux Enterprise Server 10 SP2, if the client machine run XP all works fine. I disabled the firewalls in the both sides.

View Replies View Related

Networking :: Create A New Text File In FTP Server

Jun 26, 2015

I am trying to create a new text file in FTP Server using FTPClient but im not able to do. By using storeFile method i can only upload file that is already exists in my local system. But my requirement is to create file directly into FTP Server.

View Replies View Related

Networking :: Intercept All Outgoing HTTP Calls

Dec 12, 2014

Similar to HttpFilter  (javax.Servlet.Filter ) which when added in web.xml can intercept any incoming request to JVM / outgoing (as response) independent of framework ( Spring/CXF/Jersy etc ) without any code changes (excluding the filter itself), I am trying to find an API or approach which could intercept any outgoing HTTP calls from JVM to add/modify headers independent of framework.
 
Quite often the word Outgoing HTTP call is misinterpreted in the forums so let me explain with example.
 
Let us assume there are two JVMs, jvm1 and jvm2. and there are HTTP calls being made from JVM1 to JVM2. I would like to intercept the HTTP connection being made from JVM1 to modify the headers information before the call happens. I do not want the code to be tied to a specific framework so that I can as bundle the interceptor as a jar and share it with application team. Changes in web.xml is fine.

View Replies View Related

Networking :: Connect FTPClient To IBM 4690 OS Server

Apr 17, 2008

I'm facing some problem connecting to a IBM 4690 OS Server with the FTPClient class from the commons-net-1.4.1 library. It seems it can't read the folder on the server. The problem is that using the FTP client from Internet Explorer is works perfectly.

Here is my code (kind of hardcoded but it's only to test).

         FTPFile[] files = null;
          try {
               files = listFiles(remoteFolder);
          } catch (ParserInitializationException e) {

[Code] ...

Here is the ParserInitializationException that it throws:

org.apache.commons.net.ftp.parser.ParserInitializationException: Unknown parser type: OS 4690 operating system
     at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:118)
     at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2358)
     at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2141)
...

I've tried to use many of the FTPFileListParser available but without success. How could I handle the problem? Where could I find a Parser that would works?

View Replies View Related

Networking :: Unable To Connect Remote Machine - Network Path Was Not Found

Jan 30, 2014

I am trying to connect a remote machine but I can't. There is a shared folder in the remote machine, when I write the path to file browser in local machine, it does not find the path specified. Both machines have successful network condition and ping each other. Also, the shared folder is opened to everyone, there should not be a permission problem, right?

View Replies View Related

What Handling Exception And Declaring Same Exception In Throws Clause Achieve

Jan 24, 2014

I was giving a quick skim to some tutorials on the internet where I have found the exception that is handled is also declared in the throws clause of the method wrapping the try-catch block. For a code representation consider the following:

public void methodName() throws IOException {
try {
...
} catch (IOException ex) {
.... TODO handle exception
}

}

View Replies View Related

JSP :: Using Socket For Chatting?

Feb 13, 2014

I'm developing a web-based chatting system using JSP and socket.

The problem i am facing is that the sender can send message but on the receiver side we have to manually refresh the page. The sender stays into blocking mode until the receiver refresh its page !

after that i've implemented auto-refresh on the receiver side and "Connection Refused" exception is generated.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved