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
ADVERTISEMENT
Jun 17, 2013
At first, oracle change this site a lot. I logged into this site after a long time and I was amazed to see the new changes. Moving onto the the question.
I am developing a spring mvc web application. The problem is when I send email, let say to more than 4 person, the program hangs for a while. Some friend told me to use thread pool to solve this. What is the general practice for handling this kind of situation?
View Replies
View Related
May 6, 2015
I have an app that is randomly hanging it doesn't give any error information when it hangs.
Is there at way to see what's going on when it hangs? e.g. the methods that are being called, where is the program execution at..
View Replies
View Related
Nov 7, 2014
We have a java application in our production enviroment using Spring framework which is configured with DBCP connection pool and the backend is Oracle database( version 11.2.0.3). Recently we encountered an occasionally happened situation(about once every week) and can be described as below:
The application schedules a task that runs every 10 minutes. And during task execution, the application would issue a SQL query of which the result is expected to be got within 10 seconds. At 11:51 a.m Oct 13th, however, the application failed to get the result within expected time, and 2 hours later, at 13:51, the result was finally returned to application. Due to lack of information at that time, we were not able to reproduce the same problem in test environment. At 15:31 p.m, Oct 29th, it happend again and this time we grasped all the information including thread dump and Oracle diagnostic information. We could found that:
1. Through oracle v$sql view, we could find that the SQL query is executed twice, at 15:31 and 17:31 respectively.
2. By analyzing TCP packets provided by network monitoring tools, it can be concluded that the request TCP packet containing SQL statement had been sent to Oracle and get executed, but after that JDBC only fetched first 80000 records out of 90000 records in total and then it stopped, didn't send any more request to Oracle to fetch rows. 2 hours later, Oracle sent a TCP keep alive packet and JDBC driver resume fetching remaining rows using the same connection(which can be confirmed by comparing source port of packets).
3. We dumped the thread at which JDBC hangs at socket read of JDBC driver
By the way, the version of JDBC we use is 11.2.0.1 and JDK version is 1.5.0_22.
The SQL statement is very simple:
select sum(n.netvalue) npvi,
n.HISCENEID hsid,
n.counterpartyid cid,
n.productid pid,
n.opendays
[Code] .....
View Replies
View Related
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
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
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
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
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
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
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
View Related
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
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
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
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
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
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
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
Apr 11, 2014
I have developed a code to connecting remote windows M/C from local M/C by using SSH2 (ganymed-ssh2-build209.jar) API. when I run the code its giving below error. Is there any other way to connect remote windows system using java code.
Exception.
java.io.IOException: There was a problem while talking to <host name>:22
at ch.ethz.ssh2.Connection.connect(Connection.java:642)
at ch.ethz.ssh2.Connection.connect(Connection.java:460)
at Connect.RemoteServer.ConnectWindowsServer.runCommand(ConnectWindowsServer.java:55)
at Connect.RemoteServer.ConnectWindowsServer.main(ConnectWindowsServer.java:27)
Caused by: java.net.ConnectException: Connection refused: connect
[Code] ....
JAVA Code
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.Session;
public void setAuthenticationInfo(String hostname, String username,String password) {
this.host = hostname;
this.userid = username;
this.password = password;
this.recentCommand = "";
System.out.println("setting authentication info completed for host=" + host );
[Code] .....
View Replies
View Related
Apr 12, 2015
I am writing a program that needs to read from a file, but I can't even get it to open. I have tried saving the .txt file 2 different ways. First, I saved the file to my src/package folder. Then I tried just the src folder. Then I tried going through Import/general/filesystem/ and selecting the root directory. However, my program is still unable to open the file.
private void readFile(String filename){
Scanner file;
try {
file = new Scanner(new File(filename));
System.out.println(file);
file.close();
} catch (Exception e){
System.out.println("Could not find file");
}
}
What am I doing wrong? How/where should I put the file?
View Replies
View Related
Nov 16, 2014
How to read xml tag <br/> without encoding in java. After encoding it becomes <br>. I dont want to encode it. I already tried CDATA[ and StringEscapeUtils.unescapeXml and StringEscapeUtils.unescapeHtml, but unable to change the decode it.
View Replies
View Related
Jul 21, 2014
How do I get my program to read .txt files? My code doesn't work. I use eclipse.
I tried to use FileReader and BufferedReader objects, but the code doesn't work.
How do I get my program to read .txt files in java?
View Replies
View Related
Feb 4, 2014
I am trying to do a read/write int property called currentQuestionIndex. This property is the index of the question currently selected, and the value of the property is 0 when a DrivingTest object is first created. I dont understand how to do this. I am not sure how to get the index of the current question. i was trying to use an iterator but i dont think i was doin it right. My question class that hold all my data
package cs320Labs.servlet;
public class Question {
String description;
String answerA;
String answerB;
String answerC;
int correctAnswer;
[Code] ....
View Replies
View Related
Feb 28, 2014
I am trying to have a program go on one of the stock trading websites and read the number a stock or currency is at and display or save it. I have it reading and displaying the binary code but I don't see how to have it find the numbers I would like to get.
On the site you would have to go on the page and click some tabs to trade and maybe the stock you would like, it doesn't really matter what one it returns as this is more just an idea. Although I would like to have it search out a selected stock eventually to take it to the net level. I think my biggest problem is I can't see how to access the stock numbers in the code. I looked for different click events but don't see how to have a program do this.
I do not intend to have it display all the code like it is now. I just did it like that to see what I was getting. I will just have a small toolbar with options and a display.
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
public class StockTracker {
public static void main(String[] args) {
[Code] ......
View Replies
View Related
Apr 5, 2014
I am creating a hangman game and I want to read in a list of words from a text file, but after the user inputs the name of the text file. I get 'Exception in thread "main" java.lang.NullPointerException'.
Here is the code, where I think the problems lie.
public void runModel(){
ArrayList<String> pirateWordsList = new ArrayList<String>();
System.out.println("What is the name of the file you would like to load? (The file included is called piratewords.txt'");
Scanner in=new Scanner(System.in);
String file=in.next();
load(file);
[Code] ....
The full error message is this:
Exception in thread "main" java.lang.NullPointerException
at uk.ac.aber.dcs.pirate_hangman.Model.load(Model.jav a:108)
at uk.ac.aber.dcs.pirate_hangman.Model.runModel(Model .java:45)
at uk.ac.aber.dcs.pirate_hangman.Main.main(Main.java: 6)
View Replies
View Related
May 2, 2014
I do not know how to read a name which has spaces in Java and I wish to learn. The following is my code
import java.util.*;
public class Asking {
public static void main(String []args) {
Scanner reader = new Scanner(System.in);
String [] names = new String[20];
int [] marks = new int[20];
[code]....
View Replies
View Related