javasocketbridge - client not reading / java.net.SocketPermission - java

I am trying to achieve a TCP connection between a JavaScript client and a java server. (implementation must be this way I cannot swap to node for the server for example ).
Web sockets implmentation in java looked very complicated. I had a look at Jetty and JWebSocket and was quickly scared off. I have no idea what is going on in the source for them. – So I didn’t have much luck implementing a server using them.
So then I looked for websocket alternatives.
I noticed SocketBridge, It seems very straight forwards and offers exactly what I need for my project so I downloaded that.
I created a simple java server that just prints what I receives and sends a string as bytes back. I used the prebuilt JavaSocketBridge and modified the index.html to point to my server. My server recived the message but nothing showed up on the client.
function run(){
socket_connect('localhost', 31113);
socket_send("Hello from JavaSocketBridge applet");
}
I then decided to build the JavaSocketBridge to see if I could debug the read methods. However my build of JavaSocketBridge refuses to connect with the error.
Java Socket Bridge ERROR: Could not connect to localhost on port 31113
Access denied (“java.net.SocketPermission” “127.0.0.1:31113” “connect,resolve” )
(This was in chrome but it happens in firefox too)
So my questions:
Why does my build get a socket permission error?
Why does the client not receive anything even though the example does from google.com:80?
Notes.
My server appears to be working fine. (I have used a simple java client to test it.
I have used java 1.6 and 1.7 to build the JavaSocketBridge)
I have included C:\Program Files\Java\jre7\lib\plugin.jar
My System is Win7 64 and java SDK / JRE is up to date
Edit. Ive gone back to jetty and got a client/server working, however I will monitor this question.

Related

Not able to record in Jmeter after OS reinstallation

I am using Jmeter 2.13 version and with that I used to record many scripts earlier successfully without any issue . Now, my OS has been reinstalled and I am holding Windows 8.1 , 64 bit version.After re installation, I am not able to record HTTPS web applications even though my proxy configuration is correct. After I setup everything in Jmeter, and click on start from work bench and I navigate to the browser try to access the application, it shows "Server not found" message.
However, the scripts which I saved earlier are working fine without any issues. only the new recording is not working.
Help me with the possible solutions.
"Server not found" indicates that browser is unable to access Internet (or intranet).
Most likely you're sitting behind the corporate proxy server and in previous JMeter installation you had these proxy server details specified in system.properties file like:
http.proxyHost=10.20.30.40
http.proxyPort=3128
https.proxyHost=10.20.30.40
https.proxyPort=3128
Double check with your network administrator if this is the case, if yes - take steps from Using JMeter behind a proxy User Manual chapter.
You can also try out JMeter Chrome Extension as an alternative solution - in that case you don't have to worry about proxies and SSL certificates substitution.

HTTP or FTP for client/server application in java

im Trying to Write a Windows client-server Version control application .
i've created two servers , one works with java socket ( java.net library ) to handling the requests ( login, signup and ... ) coming from client . and the other server is running on FTP protocol (using apache common net library) for serving my files .
and client is able to communicate with the first server over tcp socket and download or upload files to the second server using FTP .
but recently someone just told me that i should use HTTP instead of both . because HTTP in java in really easy to use for both communicating and FILE serving and most importantly is its able to traverse the NAT which now what im using is not able to do .
now im wondering is he right ? should i change my servers to use HTTP instead of TCP socket and FTP ? whats the benefit ?
There's some advantages of changing your protocol stack to HTTP:
You can easily add security later (only a matter of a single 's')
You don't have to do two servers, you can do all-in-one.
At some point you could offer a browser-based access of you don't have the client installed / work of a decive where you cannot install it
HTTP webapps (even those in java) are proven to scale very, very well. So once you have a lot of users, you're still good to go.
There's a lot of helpful frameworks out there that can help you focus on the what instead of the how
Most companies that allow outside-access at all will have HTTP/HTTPS open. FTP is more limited in most places.
NAT traversal / Proxy traversal
and that's only the ones I came up with while typing :-)
Downsides:
You have to start over. But: If you run into trouble, Stack Overflow is there to help you out.

SFTP to FTP bridge

I would like to connect with an SFTP client to an FTP server using java. I know the two technologies have nothing to do with each-other. What I'm trying to accomplish is to connect to an FTP server via the internet with out using two ports or changing the server configuration.
Is there any SFTP->FTP bridge in java it would be great. If not, how can I accomplish that ?
I would like to incorporate this in an exciting java server so hence, java based solutions are preferred. If there is some standalone software which you can control via code than it should support windows and *nix.
(Since SFTP is just the means here, a similar WebDav solution will also work)
You could go with trial and error. Try this out see if it works.
How to retrieve a file from a server via SFTP?

Tomcat websockets and separate java process communication

I have a tomcat 7.0.53 server running for the purpose of communicating between java and the website through websockets. I wrote the website script as well as the websocket server java code and they communicate and work correctly. However the information I want passed to the website is from another java program running in the background on a Linux machine. The problem lies however with that when I try to pass messages into a sendmessage type of function on the websocket server java code, it thinks that no sessions are open to send the websocket message to even if I do have the website opening waiting for a message from the separate java process to be passed through the websocket server. I found out this problem arises since I have to make a new instance of the websocket server when passes messages from my separate java process into the websocket server sendmessage function and thus there are no websocket sessions in that instance. I am stumped as to a way around this problem other then to making a socket between my websocket server and the other java process running which will be messy and want to avoid. Does anyone else know anyway else this can be done with communicating a separate java process with a websocket server for tomcat, or is this just impossible to do without making a socket?
I'm not entirely sure I understand your question. Could you share the code you are using to provide more context as to what you are attempting server side?
I believe you should be able to create a websocket client endpoint from the second java program. You can find examples of java websocket clients in the web such as the following:
http://www.hascode.com/2014/11/creating-different-websocket-chat-clients-in-java/
hope this helps

Java server software not recieving connections when compiled to executable Jar

I have written code for a tcp (SSL) server which receives client connections and distributes data to the clients. the server GUI is based on JavaFX. When i run the server software from within Net Beans or Eclipse it works fine, receives client connections and sends and receives data. But when i compile the code into an executable Jar the server does not receive connections and client code throws: Connection refused exception.
I have tried pinging the server and it seems the server does not listen to the specific port when it is run from the executable Jar but DOES when run from within the IDE.
to be honest , I have no idea what could be causing this behavior. would appreciate any insights , suggestions or leads into how to fix this issue. I dont think the specific code is relevant but if somone thinks it is i will post the server code.
Well, turns out the problem was that the relevant keystores were not being loaded right. They were being loaded as FileInputStreams which will not work when embedded inside a Jar file.
I reverted them to being loaded as InputStreams , which work just as well with the SSL context and everything seems to be working right now.
Thanks a bunch for all the suggestions they defiantly helped me eliminate things along the way.

Categories

Resources