Start Appium server on Mac machine but eclipse and all code is on other windows machine

Hi All,

I have written code to start and stop Appium when the eclipse and appium are installed on same Mac machine but I need to setup migrate Eclipse and Code on windows machine and Appium exists on Mac. The Issue I am facing is how to start Appium on Mac machine from execution of code i.e sending request from windows machine (where code is existing).

Please suggest.

thanks,
Ashish Bajpai

@AshishBajpai,
You can enable telnet on mac and write a java code to open cmd and do telnet and start appium server on mac, this will work.

Hi @Appium_Master can ,
Can you tell me procedure to start appium in mac from windows?
please share the code for the above.

Hi @AshishBajpai,
Did you got the solution for above question ?
if yes please share me the sample code for that.I am also facing that same problem.

@Yosuva, @AshishBajpai.
I created a video, how we can start appium server which is present on mac os from windows. I hope it will help you to resolve you issue.

Hi @Appium_Master , can you please share the code for the above video

Hi @Appium_Master ,
when i telnet the ip of the Mac i am getting java.net.ConnectException

Please find the below code which is used

 package com.appiumproj.test;

import java.io.InputStream;
import java.io.PrintStream;

import org.apache.commons.net.telnet.TelnetClient;

public class AppiumonremotefromWIndowstoMac {
	
	private TelnetClient telnet = new TelnetClient();
	private InputStream in;
	private PrintStream out;
	private String prompt = "$";
	
	public AppiumonremotefromWIndowstoMac(String server, String user,String password){
		
		try{
			// Connect to the specified server
			
			telnet.connect(server, 23);
			// Get input output stream refernce 
			in = telnet.getInputStream();
			out = new PrintStream(telnet.getOutputStream());
			
			// log the user ON
			
			readUntil("login: ");
			write(user);
			readUntil("Password:");
			write(password);
			
			// Advance to prompt 
			
			readUntil(prompt +"");
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
	}
	
	public void su(String password){
		try {
			write("su");
			readUntil("Password: ");
			write(password);
			prompt ="$";
			
			readUntil(prompt +"");
			
		}catch(Exception e){
			e.printStackTrace();
		}
		}

	public String readUntil(String pattern){
		try {
			char lastChar = pattern.charAt(pattern.length()-1);
			StringBuffer sb =new StringBuffer();
			boolean found = false;
			char ch = (char) in.read();
			while(true){
				System.out.println(ch);
				sb.append(ch);
				if(ch ==lastChar){
					if(sb.toString().endsWith(pattern)){
						return sb.toString();
					}
				}
				ch=(char) in.read();
				
			}
		}catch(Exception e){
			e.printStackTrace();
			
		}
		
		return null ;
		
	
	}
	
public void write (String value){
	try {
		out.println(value);
		out.flush();
		System.out.println(value);
	} catch(Exception e){
		e.printStackTrace();
		
	}
}

public String sendCommand (String command){
	try {
		
		write(command);
		return readUntil(prompt + "");
		
		
	} catch(Exception e){
		e.printStackTrace();
		
	}
	
	return null ;
}

public String startServer (String command){
	try {
		write(command);
		return readUntil(prompt + "");
		
		
	} catch(Exception e){
		e.printStackTrace();
	}
	return null;
}

public void disconnect(){
	try {
	telnet.disconnect();	
	} catch(Exception e){
		e.printStackTrace();
		
	}
}

public static void main (String[] arg){
	try{
		
		AppiumonremotefromWIndowstoMac telnet =new AppiumonremotefromWIndowstoMac("192.168.1.105", "userNameofMac", "password");
		System.out.println("Got connection..");
		telnet.startServer("node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
		System.out.println("");
		System.out.println("Server Started");
		
	}catch(Exception e){
		e.printStackTrace();
		
	}}

	
}

//////////////////////////////
Please find the Below Error which we get

java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:53)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:162)
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.(AppiumonremotefromWIndowstoMac.java:20)
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.main(AppiumonremotefromWIndowstoMac.java:134)
java.lang.NullPointerException
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.write(AppiumonremotefromWIndowstoMac.java:86)
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.startServer(AppiumonremotefromWIndowstoMac.java:112)
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.main(AppiumonremotefromWIndowstoMac.java:136)
java.lang.NullPointerException
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.readUntil(AppiumonremotefromWIndowstoMac.java:62)
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.startServer(AppiumonremotefromWIndowstoMac.java:113)
at com.appiumproj.test.AppiumonremotefromWIndowstoMac.main(AppiumonremotefromWIndowstoMac.java:136)
Got connection…

Server Started

///////////////////////////////////////

Also we tried the same in comment prompt by telnet

Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Users\SystemuserName>telnet 192.168.1.125
Connecting To 192.168.1.125…Could not open connection to the host, on port 23:
Connect failed

@Yosuva : Please check your telnet server is running on mac. After that try once again

Hi @Appium_Master,
From mac machine i am able to open windows command prompt(telnet 192.168.1.113).But From window i am not able to open terminal.I am getting bellow error message.

C:\Users\SystemuserName>telnet 192.168.1.125
Connecting To 192.168.1.125...Could not open connection to the host, on port 23:
Connect failed

please help me to solve this problem.

@Yosuva : If you are facing issue with telnet , then you can have a try with ssh.
Before doing any code related try

  1. Open mac and system properties and tick remote login
  2. open windows machine and install openssh and set path
  3. open cmd and try ssh root@hostIpaddress

IF you are able to do that then convert you code to sshClient. Take a help of below link

Hi Appium_Master,

How to do the telnet session in a separate command prompt window by using eclipse?
i usually run all my scripts through elcipse(of windows machine). starting telnet session with mac in a separate windows command prompt window would be more convenient

Thanks,
Sugumar

telnet session started with mac machine and i can able to see the appium server log in eclipse(windows pc)

but what happened know, when i start executing my scripts in eclipse, application opened in mobile device (connected with Mac) and closed immediately

i mean appium server process terminated by script execution in eclipse

any thoughts on this?

Thanks,
Sugumar