Getting "Couldn't start a new session. Possible causes are invalid address of remote server pr browser start-up failure" - ios-simulator

I am new to appium and I have started working on ios-app automation in MAC.
I was able to launch the app yesterday, but today its giving me an error as "Couldn't start a new session. Possible causes are invalid address of remote server pr browser start-up failure" when I run the script in eclipse.
I started Appium server before running script, nothing is logging in it as shown below.
[Appium] Welcome to Appium v1.10.0
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
please see my code below
package com.ivy;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.AutomationName;
import io.appium.java_client.remote.MobileCapabilityType;
public class LandingPage {
IOSDriver dr;
#Test
public void IstTest() throws MalformedURLException
{
DesiredCapabilities dc = new DesiredCapabilities() ;
dc.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6");
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "IOS");
System.out.println("ios");
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION,"12.1");
System.out.println("12.1");
dc.setCapability(MobileCapabilityType.AUTOMATION_NAME,AutomationName.IOS_XCUI_TEST);
System.out.println("ios_xcui_test");
dc.setCapability(MobileCapabilityType.APP,"/Users/apple/Library/Developer/Xcode/
DerivedData/MyIvyPage-ahclijlgxyrbtydlllbomcworphc/Build/Products/Debug-
iphonesimulator/MyIvyPage.app");
IOSDriver dr= (IOSDriver) new RemoteWebDriver(new
URL("https://127.0.0.1:4723"), d);
What am I missing? Please help me out!

you have a wrong Url when you try to create a session, the Url Should be.
"http://127.0.0.1:4723/wd/hub";

Please correct the below line your code
IOSDriver dr= (IOSDriver) new RemoteWebDriver(new
URL("http://localhost:4723/wd/hub"), d);
Then your code should work.

Related

Getting Unknown Host Exception While using RestFb

I Want to Connect to get data from facebook using restFb but it is throwing Unknown host Exception .
My code
package com.resrfb;
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.types.User;
public class SimpleMeExample {
public static void main(String[] args) {
FacebookClient facebookClient= new DefaultFacebookClient("Key");
User user = facebookClient.fetchObject("me", User.class);
System.out.println("User="+ user);
System.out.println("UserName= "+ user.getUsername());
System.out.println("Birthday= "+ user.getBirthday());
}
}
Also i wanted to know how to get data from any user that login to my web app using restfb as here i am geeting my accesstoken manually how to get it for any user when logging in using facebook sdk.
Stack Trace
Exception in thread "main" com.restfb.exception.FacebookNetworkException: A network error occurred while trying to communicate with Facebook: Facebook request failed (HTTP status code null)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1024)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:952)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:914)
at com.restfb.DefaultFacebookClient.fetchObject(DefaultFacebookClient.java:392)
at com.resrfb.SimpleMeExample.main(SimpleMeExample.java:14)
Caused by: java.net.UnknownHostException: graph.facebook.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:559)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:272)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:329)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:133)
at com.restfb.DefaultWebRequestor.execute(DefaultWebRequestor.java:374)
at com.restfb.DefaultWebRequestor.executeGet(DefaultWebRequestor.java:96)
at com.restfb.DefaultFacebookClient$3.makeRequest(DefaultFacebookClient.java:965)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1022)
... 4 more
Your machine cannot connect to Facebook, this error is on a lower level and not RestFB dependent. You should check your DNS settings, hosts file and your proxy settings.

Elasticsearch not starting, but throwing ReceiveTimeoutTransportException

I am trying to use elastic search with java api, but when i try to run application, i am getting following exception.
18:13:52.378 [elasticsearch[Fallen One][generic][T#1]] INFO org.elasticsearch.client.transport - [Fallen One] failed to get local cluster state for [#transport#-1][integra][inet[/127.0.0.1:9300]], disconnecting...
org.elasticsearch.transport.ReceiveTimeoutTransportException: [][inet[/127.0.0.1:9300]][cluster/state] request_id [52] timed out after [5001ms]
at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:356) [elasticsearch-1.0.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]
18:13:52.381 [elasticsearch[Fallen One][generic][T#1]] DEBUG org.elasticsearch.transport.netty - [Fallen One] disconnected from [[#transport#-1][integra][inet[/127.0.0.1:9300]]]
18:13:52.391 [elasticsearch[Fallen One][generic][T#3]] DEBUG org.elasticsearch.transport.netty - [Fallen One] connected to node [[#transport#-1][integra][inet[/127.0.0.1:9300]]]
Code for connecting to elastic search is
private String[] esNodes = { "127.0.0.1:9300" };
protected TransportClient buildClient() throws Exception {
Settings settings = ImmutableSettings.settingsBuilder()
.put("client.transport.sniff", true)
.put("client.transport.ignore_cluster_name",true).build();
TransportClient client = new TransportClient(settings);
for (int i = 0; i < esNodes.length; i++) {
client.addTransportAddress(toAddress(esNodes[i]));
}
return client;
}
private InetSocketTransportAddress toAddress(String address) {
if (address == null) return null;
String[] splitted = address.split(":");
int port = 9300;
if (splitted.length > 1) {
port = Integer.parseInt(splitted[1]);
}
return new InetSocketTransportAddress(splitted[0], port);
}
can any one kindly help me, i am new to elastic search and have no idea how to resolve the issue.
I am using this code to connect to my elasticsearch and its pretty well working.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", clusterName).build();
this.client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(ipAddress,9300));
Where ipAddress and Clustername are argument of my function.
You should have a look at the network on your laptop. Check if you can connect to localhost. Another thing you could try is start two elasticsearch instances with the same configuration to see if they connect. Finally have a look at the network part of elasticsearch.yml. When having network problems on a local machine I usually try the following two options:
network.host: localhost
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["localhost"]
I think Elastic search server is Not started.. Try to hit in browser or curl comments.. If it works.. Try the above code..
NOTE:IF YOUR JAVA API JAR VERSION DIFFERS ALSO LL RAISE PROB.. ( get java api version same as ES version
Note : elasticsearch java api helps you connect to with elasticsearch.. But its can't start a elasticsearch node using api..
Your code is good.. It's Vry standard too..

SSLSocketFactory.createSocket connects using http instead of https

I need to make a handshake. I do it with the code below.
I'm running the code in an applet and it works fine when running directly against the server. The problem I have occurs when the same code runs via a proxy.
I'm looking in the java console with trace level 5 activated. Directly after the code line "SSLSocket socket = (SSLSocket) factory.createSocket("www.theserver.com", 443);" is executed
this line appears in the java console "network: Connecting http://www.theserver.com:443 with proxy=DIRECT". After this the applet stops working. I think it is because the
proxy will not allow http traffic on port 443.
Can anyone tell me why it is connecting using http and what I should do to make it connect using https?
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class Handshake
{
class MyHandshakeListener implements HandshakeCompletedListener
{
public void handshakeCompleted(HandshakeCompletedEvent e)
{
System.out.println("Handshake succesful!");
System.out.println("Using cipher suite: " + e.getCipherSuite());
}
}
public void DoHandshake()
{
try
{
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket("www.theserver.com", 443);
String[] suites = socket.getSupportedCipherSuites();
socket.setEnabledCipherSuites(suites);
socket.addHandshakeCompletedListener(new MyHandshakeListener());
socket.startHandshake();
}
catch (Exception e)
{
System.out.println(e);
}
}
}
I know this is a little late, but we had the exact same problem and was just able to resolve it. The problem was on the client, the "Use SSL 2.0 compatible ClientHello format" was checked on the advanced tab of the Java Control Panel. Uncheck this box on the client and it will connect correctly.

Red5: Server application skeleton and helloworld

Can anyone provide an updated application skeleton for a Red5 application? From what I have found the logging system changed from Log4j. I've been looking for some tutorials just to setup everything but can't really find something that simply works.
In addiction, can anyone provide a simple tutorial with a server application and Flex client?
Thanks in advance!
I struggled a lot with that.. This reference worked for me:
http://fossies.org/unix/privat/red5-1.0.0-RC2.tar.gz:a/red5-1.0.0/doc/reference/html/logging-setup.html
The trick was to Remove any log4j.properties or log4j.xml files and Remove any "log4j" listeners from the web.xml
Create a logback-myApp.xml where myApp is the name for your webapp and place it on your webapp classpath (WEB-INF/classes or in your application jar within WEB-INF/lib)
and im my app i did:
import org.slf4j.Logger;
import org.red5.logging.Red5LoggerFactory;
and then:
private static Logger log = Red5LoggerFactory.getLogger(MyClassName.class, "myApp");
the clients actionscript looks like this:
// Initializiing Connection
private function initConnection():void{
nc = new NetConnection();
nc.client = new NetConnectionClient();
nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
nc.connect(rtmpPath.text,true); //Path to FMS Server e.g. rtmp://<hostname>/<application name>
nc.addEventListener("netStatus", publishStream); //Listener to see if connection is successful
}
private function publishStream(event:NetStatusEvent):void{
if(nc.connected){
nsPublish = new NetStream(nc); //Initializing NetStream
nsPublish.attachCamera(Camera.getCamera());
nsPublish.attachAudio(Microphone.getMicrophone()); //Attaching Camera & Microphone
nsPublish.publish(streamName.text,'live'); //Publish stream
mx.controls.Alert.show("Published");
}
else{
mx.controls.Alert.show("Connection Error");
}
}

Sent HTTP request with Credential in blackberry

I am trying to call HTTP request with network credential in blackberry. i have already implement on Java, Android it's working fine but not working on blackberry. Following step i have done in blackberry.
For set Network credential i have added three following jar.
commons-codec-1.6.jar
commons-httpclient-3.0.1.jar
commons-logging-1.1.1.jar
add this jar files are in blackberry project.
Following sample Code that work fine in Core Java.
try{
HttpClient client = new HttpClient();
GetMethod get = new GetMethod("http://www.google.com");
get.setDoAuthentication( true );
try {
int status = client.executeMethod( get );
System.out.println(status + "\n" + get.getResponseBodyAsString());
} finally {
get.releaseConnection();
}
}catch(Exception e){
System.out.println("Error:>>>>>>"+e);
}
Now there are not error on code but whenever try to click on application icon error face like "error starting appName: Module 'commons-httpclient-3.0.1' not found"
Can any one suggest what's this error say.
BB does not support HttpClient. But it does support J2ME's HttpConnection and is quite similar to HttpClient, so you can easily adjust with it. Here's some sample code to get you started:
try{
HttpConnection mConn = (HttpConnection)Connector.open(urlToPost);
mConn.setRequestMethod(HttpConnection.POST);
mConn.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT");
mConn.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
mConn.setRequestProperty("Content-Language", "en-CA");
//---------------------------------------------------
mConn.setRequestProperty("User",usr);
mConn.setRequestProperty("pass",pass);
//---------------------------------------------------
catch(Exception e){//---handle your exceptions---//}
} finally {
mConn.close();//don't forget to close connections, only a limited number are available
}
This is a good article for beter understanding.

Resources