IOS Webkit Debug proxy issue - Unable to bind device - java

I am trying to start ios webkit debug proxy by passing the udid and the port number.
Command: ios_webkit_debug_proxy -c 4ea8dd11e8c4fbc1a2deadbeefa0fd3bbbb268c7:27753 -d.
Facing issue while binding the device on port number 27753. Error message,'Unable to bind udid on port 27753-27753'

Check this web link https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/ios-webkit-debug-proxy.md, if it helps.

Most likely it cannot be bind to the port since it's already taken.
Check if the port is taken by another process (or same type of process that is hanged by some reason) by running sof -t -i tcp:27753 command in terminal.
To find and kill process run sof -t -i tcp:27753 | xargs kill command in terminal, but it's not safe to do in case if you have parallel execution and/or not only ios_webkit_debug_proxy is using port 27753.

Related

Facing issue with Tomcat execution in eclipse

I tried uninstalling and reinstalling tomcat after removing the server instance from the eclipse environment. I spent so much time yet there is no use. This is the error I keep receiving.
Error in the eclipse environment.
It says that the port 8080 required by Tomcat is in use. But in port 8080 only tomcat is running. I am attaching a screenshot for the same.Ports in Resource Manager.
Please help me resolve this issue, Thanks in advance!!!.
netstat -ano | findstr :
for example, use the below command in the terminal or cmd
netstat -ano | findstr :8080
find the process id
and then use
taskkill /PID /F
to kill the task.

bash command to wait until TCP port is opened

I want my micro services to open in a new command line and run it from there one after the other. below is my bash script
################ first SERVER #####################
gnome-terminal -x sh -c 'java -jar server/target/first-server.jar; exec bash'
################ second SERVER #####################
export service_port=8771
export host_name=firstdomain
gnome-terminal -x sh -c 'java -Dservice.port="${service_port}" -Dhost.name="${host_name}" -jar eureka/target/second-server.jar; exec bash'
The problem is it that i want to start my "second-server.jar" after successfully started the "first-server.jar". I can detect that by checking if the service is listening to network port. Is there any way to archive this? sleep bash command is not a option for me.
Basically, you need to use sleep command. But you can use it in a loop checking continuously if the port became available. But how to check availability of the port?
One option is to use netstat command as suggested by Jack. The proper usage is:
netstat -tna | grep 'LISTEN\>' | grep ':NNNN\>'
where NNNN is the port. To make that a condition to wait on, you can write following loop:
while ! netstat -tna | grep 'LISTEN\>' | grep -q ':NNNN\>'; do
sleep 10 # time in seconds, tune it as needed
done
Please mind the -q option in the last instance of grep.
The other option is to check, if you can connect to port:
{
while ! echo -n > /dev/tcp/localhost/NNNN; do
sleep 10
done
} 2>/dev/null
Depending on the distribution you are using and the options bash has been compiled with, this method may or may not working.
Another option to check if port is accessible is to use nc:
while ! nc -q0 localhost 2222 < /dev/null > /dev/null 2>&1; do
sleep 10
done
You can replace localhost with your hostname or ip address.

In Java how to programatically kill process on a specified port in Windows

Basically I am automation an application and prerequisite of my automation is that I am using several 3rd party libs which starts certain processes. At the end of the code execution, I want to close all such processes. The only thing I know is that these process runs on specific port always (for example 61120).
As part of clean up, I want to close the process running on port 61120 programatically in Java.
You could use netstat -a -b to get the executables and the port numbers. After that you can taskkill the executables by name. But i never would use this on a productive machine because it's some kind of ...ahm... dangerous.
Better to start processes by java (Runtime.getRuntime().execute(...)) and end them if you do not need them anymore.
Through this you can get the desired processes and port numbers
netstat -a -b
Then there is a little API providing the desired functionality to operate with the processes:
https://java.net/projects/winp
Windows Process Library
try
netstat -a -o -n
Search for the port you need.
If the console output is more then re-direct it to some file like:
netstat -a -o -n > {drive}:/netlog.log
search port in that log file.
taskkill /F /PID

how to stop all ports in apache tomcat

While developing a web application using Apache Tomacat and Eclipse frequently I get this message
Several ports (7354, 6544, 9999) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
I know that this ports are in use, but I don't if I stop all those servers also why get the same message. My question is - Is there any way to stop all ports at once in using Eclipse or Windows 7 ?
you can use the lsof in combination with awk. do the following:
lsof -i :<portnumber> | awk '{print "kill -9 "$2}' | sh
if you want to know only the processId from the port, use:
lsof -i :<portnumber> | awk '{print $2}'
btw: i have this problem sometimes too. If you're using eclipse check in the debug view if there is still a thread of the tomcat running. if so, stop them :)
Otherwise restart eclipse.
Have you tried the following?
ps -ef | grep <port number>
kill -9 <process id>

Address binding issue

I am trying to run a web application (which is a servlet + gradle project). I am using Jetty to run the application. When I run the application , I am getting the error:
Address already in use
Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.0-bin.zip'.
When, I enter localhost:8080 , I used to get jenkins default page, So I uninstalled jenkins and tried again, but getting the same error.
Please help in resolving this issue, also how do we get to know which application is running on corresponding port?
You can use the command "netstat". Look for the line in which the column "remote address" ends with ":8080".
Depending on the OS you're running:
Windows:
netstat -b -n -a -p TCP
The process is printed above the line.
Linux:
netstat -a -n -p | grep 8080
The process is printed as the last column of the line.

Categories

Resources