Unable to cryptoInit from java client

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

narendra3188
Posts: 2
Joined: 22 Apr 2019, 09:40

Unable to cryptoInit from java client

Postby narendra3188 » 22 Apr 2019, 10:01

SFS server version 2.13
SSL enabled

Java SFS client API version : 1.7.5
Java client sdk version :1.7


Config settings mention :

Code: Select all

<ip>192.168.67.229</ip>
    <udpIp>192.168.67.229</udpIp>
   <port>9933</port>
    <udpPort>9933</udpPort>
   <zone>BasicKing</zone>   
   <!-- End Mandatory Settings -->
   
   <debug>false</debug>
   
   <!-- For generic http port communication -->
   <httpPort>8081</httpPort>
   <httpsPort>8892</httpsPort>
   
   <!-- BlueBox settings -->
   <useBlueBox>true</useBlueBox>
   <blueBoxPollingRate>700</blueBoxPollingRate>   





config Load code


Code: Select all

this.sfs = new SmartFox();
      // here the true flag assures that SmartFox will automatically connect
      // to server on successful load config.
      try {
         this.sfs.loadConfig(this.getCfgPath(), true);
      } catch (Exception e) {
         // System.out.println("Unable to connect to host.");
      }


Connection code handler

Code: Select all

this.sfs.addEventListener(SFSEvent.CONNECTION, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
            Map params = evt.getArguments();
            boolean isSuccess = (Boolean) params.get("success");
            
            if (isSuccess) {
               //useEncryption = true;
               if(useEncryption){
                  try{
                  this.sfs.initCrypto();
                  }catch(Exception e){
                     System.out.println(" exception in initCrypto " + e);
                  }
                  /* The below line is not getting executed once above line is executing*/
                  System.out.println("BotSpawner.Connection established; Crypto Intialization  Done");
               }
            } else {
               System.out.println("BotSpawner.Connection failed");
               
            }
         }
      });


Crypto Handler

Code: Select all

this.sfs.addEventListener(SFSEvent.CRYPTO_INIT, new IEventListener(){
         @Override
         public void dispatch(BaseEvent evt) throws SFSException {
            
            Map params = evt.getArguments();
            boolean isSuccess = (Boolean) params.get("success");
            if(isSuccess){
               this.sfs.send(new LoginRequest("ram","********","2");
            }else{
               System.out.println("Current Thread Name CRYPTO_INIT  intialization falied:" );
            }
         }
         
      });




Exception faced :


Code: Select all

 SFSWorker:Sys:4 | controllers.v290.SystemReqController |     | com.smartfoxserver.v2.exceptions.SFSRuntimeException: Login rejected. Client is not using an encrypted connection: { Id: 248, Type: DEFAULT, Logged: No, IP: 192.168.67.229:44120 }
   com.smartfoxserver.v2.controllers.system.Login.validateEncryptionStatus(Login.java:130)
   com.smartfoxserver.v2.controllers.system.Login.validate(Login.java:66)
   com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:168)
   com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:127)
   com.smartfoxserver.bitswarm.io.protocols.AbstractProtocolCodec.dispatchRequestToController(AbstractProtocolCodec.java:39)
   com.smartfoxserver.v2.protocol.SFSProtocolCodec.dispatchRequest(SFSProtocolCodec.java:133)
   com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketRead(SFSProtocolCodec.java:90)
   com.smartfoxserver.v2.protocol.binary.BinaryIoHandler$1.run(BinaryIoHandler.java:477)
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   java.lang.Thread.run(Thread.java:748)

User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unable to cryptoInit from java client

Postby Lapo » 22 Apr 2019, 17:01

Hi,
are you sure the CRYPTO_INIT is returning a positive result? i.e. the "success" parameter is set to true?
I ask because in your XML config you're using the IP address of the server, rather that its domain name. When you need to use SSL you should always use the domain name because that's the only thing covered by the SSL certificate.

In other words trying to connect via SSL to an IP address always fails.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
narendra3188
Posts: 2
Joined: 22 Apr 2019, 09:40

Re: Unable to cryptoInit from java client

Postby narendra3188 » 23 Apr 2019, 06:00

Hi

"are you sure the CRYPTO_INIT is returning a positive result? i.e. the "success" parameter is set to true?"
Lapo, the moment the following code gets triggered it gets stuck there, also we do not get CryptInit response.

Code: Select all

       try{
                  this.sfs.initCrypto();
                  }catch(Exception e){
                     System.out.println(" exception in initCrypto " + e);
                  }
                  /* The below line is not getting executed once above line is executing*/
                  System.out.println(" Crypto Intialization  Done");

Not sure why the code is not gettting executed properly. Any idea what could be wrong?
This console " Crypto Intialization Done" is not printing and also no exception console!!

"I ask because in your XML config you're using the IP address of the server, rather that its domain name. When you need to use SSL you should always use the domain name because that's the only thing covered by the SSL certificate. "
Its a dummy ip i posted here, we are using regular SSL domain name only in xml config.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unable to cryptoInit from java client

Postby Lapo » 23 Apr 2019, 07:18

Can you send me the domain name of the server via private message so we can test from here?
Also if the port numbers are different from those in the config, tell us the correct ones too.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 13 guests