I've written a software module in PHP that manages the saving of data in different data stores (MySQL, ElasticSearch and Redis). To test the module, I've created several test plans in Apache JMeter, including some that make a lot of concurrent requests. The tests are run against a LAMP stack in an Ubuntu 14.04 LTS VM (a Vagrant box).
What I've observed is, that sometimes port 9200 (ElasticSearch) gets closed after a given number of requests. Which is fine, because I want to test scenarios where one of the data stores becomes unavailable. However, to validate the test results, I need that port open again.
ElasticSearch is still running and listening to the port.
Situation before test run
$ nmap -p 9200 localhost
(...)
PORT STATE SERVICE
9200/tcp open wap-wsp
$ sudo netstat -tlnp | grep '9200'
tcp6 0 0 :::9200 :::* LISTEN 1057/java
Situation after test run
$ nmap -p 9200 localhost
(...)
PORT STATE SERVICE
9200/tcp closed wap-wsp
$ sudo netstat -tlnp | grep '9200'
tcp6 0 0 :::9200 :::* LISTEN 1057/java
Question
So far, I've waited until the store opened up again or I've restarted the VM. However, this is very inconvenient, which leads me to the actual question:
Is there a command to re-open a closed port?
I've searched, but only found advise on how to configure iptables
. I've tried
$ sudo iptables -A INPUT -d 0/0 -s 0/0 -p tcp --dport 9200 -j ACCEPT
But from what I gather, this only creates a rule, and it doesn't have any immediate effect on the port:
$ sudo iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:9200
$ nmap -p 9200 localhost
(...)
PORT STATE SERVICE
9200/tcp closed wap-wsp
Best Answer
I think that this java application listening on port 9200 just crashed and you need to restart it.
From
netstat -nlpt | grep 9200
, you can get the process id (just next to /java at the end).Then with that id, run:
ps aux | grep [process id]
to find out what's the java app if you don't already now and just restart it, that should solve your issues!