Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have ReST service, which calls a method to send the generated information to another endpoint using TCP, is there any way that with Jmeter that when I send a ReST request and should be able to host TCP server in my JMeter to receive the response sent when service called?
If you need to have a TCP server in JMeter you can get one using JSR223 Sampler and the following minimal code snippet:
def socketServer = new ServerSocket(1234)
while (true) {
socketServer.accept { socket ->
socket.withStreams { input, output ->
log.info("Received message: ${input.newReader().readLine()}")
}
}
}
it will start the TCP server on the port 1234, listen to incoming connections and printing the received data to jmeter.log file
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
If you're receiving HTTP, not TCP you might rather want to go for HTTP Mirror Server which is listening to incoming HTTP connections and returns the received data
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I know that http 503 means that the "server is unavailable" as mentioned in mozilla docs. But, if the server is unavailable or offline, then how is that server able to return a 503 response ? Is the client getting timed out and assuming a 503?
UPDATE -
I learned that there is often "middle man" such as a load balancer which gives the 503 when the backend is down. So, what if there is no middle man? Would you get an http 408 in that case?
PS - Java and Python tags are added only to get more attention from developers who are likely to know the answer to this question.
50x errors are for application errors. This means that if you have for example Apache2 or Nginx web server and that server communicate with backend application which is currently unavailable (down, starting, freezed, etc) you get this 503 error.
YOU -----> Apache2/Nginx web server ------> app backend = you will get 200
response.
YOU -----> Apache2/Nginx web server --XXX--> app backend = you will get 503
error.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am implementing a peer to peer networking application which involves sending an initial handshake to all the peers and thereafter communicating asynchronously while listening on a particular port. Therefore, I first need to send the handshakes to different peers using the same port which my application will be listening to thereafter. I have had some confusion on whether we can bind two different sockets to the same local port or not but it gives me a bind exception. I am not sure how this can be done.
Sockets must have unique <source address, source port, protocol (tcp/udp), destination address, destination port> tuples.
So yes, it's possible to re-use local ports by setting the SO_REUSEADDR socket option to true as long as the remote addresses are distinct.
But this is not necessary. The bittorrent protocol does not require that the local port of outgoing connections is set to any particular port. You don't have to bind outgoing connections at all. You can simply let the TCP stack figure out the correct interface and port.
Only your listening socket needs to be bound to the port which you announce. No particular address needed either, you can use the unspecified address, ::0 (for v4/v6 dual stack sockets) or 0.0.0.0 (v4 only).
so, I have to do a handshake from a port same as the one i have announced to the tracker
the spec does not say that anywhere.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on Lan Messenger, how can I check if somebody else's system has LAN plugged in?
Means, is that person Online?
Also, our hostel has LAN, and I've tried running the client server program a lot many times, but it runs fine on my system (2 clients on the same machine as server) but it doesn't run when server and client are on different machines.
The code is perfectly fine.
What could be the reason? Any special Firewall settings to be changed for allowing packets?
I'm creating a chat server using sockets right now and the way I'm doing it is I have every user query the server about every 20-30 seconds. The server keeps track of the last time a user "refreshed" itself. If a user's gone a certain time period or more without doing so, then the server tells anyone trying to contact this user that they are offline.
Here is a VERY good reference to work off of. Take a look at the Server folder for the server-side and the src folder for the client-side:
https://code.google.com/p/simple-android-instant-messaging-application/source/browse/trunk/#trunk%2FServer%253Fstate%253Dclosed
If you only want to communicate within a LAN, then the socket implementatation in that link is defininitely what you want. If you want to communicate globally( a user in 1 LAN to a user in some other LAN ) then you'll want to redesign it a little so that your server socket is actually on some server accepting client connections. The current implementation creates a server socket within each client and accepts connections from other clients trying to communicate with it. This design breaks due to NAT routers (for reasons I'd rather not explain unless you really want to know).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I was planning to create a chat messaging application wherein two or more clients can communicate but I am a little confused.
Does java can have a client to client communication using sockets?
Does the socket communication always needs a server?
Is it possible that one client will stand a server of the communication?
Do you have any tutorials for a client to client communication?
If the communication needs a server, how a can a client A see Client B's messages?
Client to client communication does not makes any sense because once a system start receiving message it is termed as server, so in communication there should be a server and client to communicate else the situation will be like two people talking and none of them listening.
Client A can act as a server and client both and so the client B,
in doing so both can communicate in two way ie send and receive information.
Yes, java can work with sockets.
For example, an "official" tutorial from Oracle: http://docs.oracle.com/javase/tutorial/networking/sockets/
But working with sockets directly requires a lot of code for encoding/decoding message from/to a binary form, separating data stream to logical "packets", handling threads and message queues, etc. Fortunately, there are network libraries which make this process much more easier. I would recommend Netty: http://netty.io/
About client/server relationships. If we are talking about TCP/IP, then yes. One side (server) always listens for connection, and the other side (client) opens a connection to the server.
If you are using UDP, however, from network point of view, all participants are equal. They just send and receive UDP packets.
Back to your chat application: the most simple solution - all clients connect to the dedicated server. Every chat message contains client id. When the server receives the message, it sends it to the client with the specified id. Thus, every client can transfer message to every other client. The server works as a "dispatcher".
If you need simple approach you can try https://httprelay.io service. What you need is just http client and no external libraries.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I need to implement a HTTP proxy server application which will proxy requests from multiple clients to a remote server.
Here are the steps:
Client forward request to proxy
Proxy forward request to server
Server returns request to Proxy
Proxy returns request to Client.
I'm just not sure how I should implement this proxy. My first thought was to implement a tomcat application which uses jersey / apache httpclient to forward the request to the remote server and return the response back to the client ?
Is there a better way to implement such a proxy server ?
The proxy would need to handle multiple threads.
You can't implement it as a servlet, and there is no reason to use any form of HTTP client.
A featureless proxy server is a really simple thing:
Accept a connection and start a thread for it.
Read the request from the client up to the blank line.
Extract the GET or CONNECT command or whatever it is and connect to the named host.
If that fails, send back an appropriate HTTP error response, close the socket, and forget about it.
Otherwise start two threads to copy bytes, one in each direction. Nothing fancy, just
while ((count = in.read(buffer)) > 0)
{
out.write(buffer, 0, count);
}
When one of those sockets reads an EOS, shutdown the other socket for output and exit the thread that got the EOS.
If the socket that was the source of the EOS is already shutdown for output, close them both.
Or use Apache SQUID.
Check out LittleProxy -- it has built-in classes for incoming and outgoing requests; you can just write your code similarly to how you would handle a HTTP request in a servlet.