cancel
Showing results for 
Search instead for 
Did you mean: 

exception in P4-HTTP

Former Member
0 Kudos

Hi

I have this P4-HTTP example

import javax.naming.InitialContext;

import javax.naming.NamingException;

import java.util.Properties;

public class ExampleTransportTypesSwitching {

   private static InitialContext ctx = null;

   public static void main(String[] args) {

   init ("P4HTTP://", "172.16.10.65", "50004", "administrator", "123QWEasd", "httptunneling");

  }

   public static void init(String schema, String host, String port, String user, String pass, String transportType) {

   try {

  Properties p = new Properties();

   if (schema == null) {

  schema = "P4://";

  }

  p.put("java.naming.factory.initial", "com.sap.engine.services.jndi.InitialContextFactoryImpl");

  p.put("java.naming.provider.url", host+":"+port);

  p.put("java.naming.security.principal", user);

  p.put("java.naming.security.credentials", pass);

   // Parameter transportType for Transport Layer Queue has value
  // "None", "ssl", "httptunneling_ssl" or "httptunneling".
   p.put("TransportLayerQueue", transportType);

   ctx = new InitialContext(p);

  System.out.println("NamingClient context: " + ctx);

  } catch(NamingException e) {

  e.printStackTrace();

  }

  }

on my server SAP NW 7.4 listen 50004,50007,50008 ports. I can send and receive successfully RMI requests, but over HTTP don't can. I got this exception

java.net.SocketException: Connection reset

  at java.net.SocketInputStream.read(SocketInputStream.java:209)

  at java.net.SocketInputStream.read(SocketInputStream.java:141)

  at java.net.SocketInputStream.read(SocketInputStream.java:223)

  at com.sap.engine.services.httptunneling.HttpLib.readLine(HttpLib.java:159)

  at com.sap.engine.services.httptunneling.HttpLib.readHeader(HttpLib.java:182)

  at com.sap.engine.services.httptunneling.HttpTunnelingSocket.createConnection(HttpTunnelingSocket.java:208)

  at com.sap.engine.services.httptunneling.HttpTunnelingSocket.<init>(HttpTunnelingSocket.java:113)

  at com.sap.engine.services.httptunneling.HttpTunnelingTransportFactory.getSocket

Please help, what I do wrong?

tnx

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

For P4HTTP default port number is 5NN05 (NN - instance number). Moreover, you need to add schema to java.naming.provider.url.

Answers (1)

Answers (1)

Former Member
0 Kudos

thanks for reply.

But in my servers don't open 5NN05 port, need enable manually ?

Former Member
0 Kudos

yes, I do all steps

1. change value, save it, and restart cluster

after restart start app

but port don't listen ((

vijay_kumar49
Active Contributor
0 Kudos

Open listen to a port using java code

import java.net.*;

import java.io.*;

public class PortMonitor {

   /**
  * JavaProgrammingForums.com
  */

   public static void main(String[] args) throws Exception {

   //Port to monitor

   final int myPort = 50008;

   ServerSocket ssock = new ServerSocket(myPort);

   System.out.println("port " + myPort + " opened");

   Socket sock = ssock.accept();

   System.out.println("Someone has made socket connection");

  OneConnection client = new OneConnection(sock);

   String s = client.getRequest();

   }

}


Please check this document. it may be useful  document 1 and document 2


Kindly let me know if you need any more information


Former Member
0 Kudos

I'm sorry, but this code where I need use,

I want to connect to SAP server with RMI-HTTP(P4-HTTP), I don't need up custom java socket server in SAP.

tnx

Former Member
0 Kudos

As stated in documentation: "When using HTTP(S) tunneling, the client has to specify the HTTP(S) port of the server in the java.naming.provider.url". For SAP NetWeaver 7.4: AS Java Ports -  SAP NetWeaver Application Server for Java Security Guide - SAP Library. For server X with instance number nn it should be 50000+100*nn+20+X*5+0. Also try to check ports via SAP MMC/MC.