question

Upvotes
Accepted
43 3 4 4

RFA login fails with unreadable characters.

Hi, I am using Java RFA6 with login and receive market data. Please note our app runs only on java 6 thus we must use RFA6.

I am facing a strange issue when I try to login with RFA. And need your help as I am not able to proceed ahead without any direction to investigate.

When I run my application from Intelij IDE with Java 1.6, it works successfully. My app is able to login and receives market data updates successfully.

However when I package my app into a WAR and launch through Jnlp, RFA login fails with below message. I am seeing some unreadable characters and IndexOutOfBound Exception in login response message.

Please note that our ADS server does not receive any login request. It seems that RFA api fails internally and sends response.

MESSAGE
	Msg Type: MsgType.STATUS_RESP
	Msg Model Type: LOGIN
	Indication Flags: 
	Hint Flags: HAS_ATTRIB_INFO | HAS_STATE
	State: OPEN, SUSPECT, NONE,  "Ø(
yConnection to tkrmdsdev01.nomura.com:14002 failed in connection Tiger::RFAFeed: java.lang.IndexOutOfBoundsException: nullR&jitkarrF
ApplicationId?215Position?10.199.92.165/MUMWD041460Role"
	AttribInfo
		Name: jitkarr
		NameType: 1 (USER_NAME)
		Attrib
			ELEMENT_LIST
				ELEMENT_ENTRY ApplicationId: Ø(
yConnection to tkrmdsdev01.nomura.com:14002 failed in connection Tiger::RFAFeed: java.lang.IndexOutOfBoundsException: nullR&jitkarrF
ApplicationId?215Position?10.199.92.165/MUMWD041460Role
				ELEMENT_ENTRY Position: Ø(
yConnection to tkrmdsdev01.nomura.com:14002 failed in connection Tiger::RFAFeed: java.lang.IndexOutOfBoundsException: nullR&jitkarrF
ApplicationId?215Position?10.199.92.165/MUMWD041460Role
				ELEMENT_ENTRY Role: 0
	Payload: None


Is it something to do with encoding that fails when runing with a WAR file?
Below is the code snippet that I use while creating login request.

loginRequest.setMsgType(OMMMsg.MsgType.STREAMING_REQ);
loginRequest.setMsgModelType(RDMMsgTypes.LOGIN);
loginRequest.setAttribInfo(null, "jitkarr", RDMUser.NameType.USER_NAME);

String defaultPosition = "1.1.1.1/net";
try { defaultPosition = InetAddress.getLocalHost().getHostAddress() + "/" +
        InetAddress.getLocalHost().getHostName(); }  catch( Exception e ) {}

OMMEncoder encoder = ommPool.acquireEncoder();
encoder.initialize(OMMTypes.MSG, 50000);
encoder.encodeMsgInit(loginRequest, OMMTypes.ELEMENT_LIST, OMMTypes.NO_DATA);
encoder.encodeElementListInit(OMMElementList.HAS_STANDARD_DATA, (short)0, (short) 0);
encoder.encodeElementEntryInit(RDMUser.Attrib.ApplicationId, OMMTypes.ASCII_STRING);
encoder.encodeString("215", OMMTypes.ASCII_STRING);
encoder.encodeElementEntryInit(RDMUser.Attrib.Position, OMMTypes.ASCII_STRING);
encoder.encodeString(defaultPosition, OMMTypes.ASCII_STRING);
encoder.encodeAggregateComplete();


loginRequest = (OMMMsg)encoder.getEncodedObject();
spec.setMsg(loginRequest);

consumer = (OMMConsumer) rfaSession.createEventSource(EventSource.OMM_CONSUMER, "Consumer", false);

loginHandle = consumer.registerClient(responseQueue, spec, this, null);

MyDispatcher responseDispatcher = new MyDispatcher(this, rfaSession.getName(), responseQueue);
ommPool.releaseEncoder(encoder);
treprfarfa-apiOMMerror-login
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Monitored by @Nipat Kunvutipongsak

Hi @ramesh.jitkar

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Hi @ramesh.jitkar

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Upvotes
Accepted
43 3 4 4

@Nipat Kunvutipongsak

ahh. I found something more interesting.

I changed my jnlp sample app to use RFA8. And it worked fine !!

To summarize

Java 6 webstart + RFA6 --> Fails

Java 8 webstart + RFA6 --> Fails

Java 8 webstart + RFA8 --> Works fine

Can you confirm if there are any API level differences in RFA6 and RFA8 that could cause this problem while launching with webstart?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@Nipat Kunvutipongsak, can you comment on this last query ?

Hello @ramesh.jitkar,

As far as I know, RFA 6 was compiled by using Java 6, RFA 8 was compiled by Java 7.

I tried to google the internet and found an issue regarding a wired behavior of the character encoding (returned value from a Charset.defaultCharset() method) between two Java versions.

Anyway, I'm not entirely sure that it relates to this problem or not, but it might give more clues to this issue.

There are several changes and bugfixes between RFA6 and RFA8. One of them could relate to this issue.
Moreover, RFA6 has been end-of-life'd and no longer supported.

Upvotes
1.9k 7 10 16

@ramesh.jitkar,

It's me from the another similar question: https://community.developers.refinitiv.com/questions/23732/indexoutofboundexception-during-rfa-login.html

As you said that you build the application using gradle, can you also try setting the character encoding in gradle's build settings and reproduce this problem again to verify whether this problem still persists or not?

Alternative#1:

compileJava.options.encoding = 'UTF-8'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

Alternative#2:

apply plugin: 'java'
tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}
repositories {
    mavenCentral()
}
....
test {
    systemProperty "file.encoding", "utf-8"
}

Alternative#3:

org.gradle.jvmargs='-Dfile.encoding=UTF-8'

Hope this helps!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
43 3 4 4

@Nipat Kunvutipongsak Thanks for your reply.

Below is the valid login response when I run application from Intelij. Meanwhile I shall try setting

Meanwhile I shall try setting character encoding as you suggested.

MESSAGE
	Msg Type: MsgType.STATUS_RESP
	Msg Model Type: LOGIN
	Indication Flags: 
	Hint Flags: HAS_ATTRIB_INFO | HAS_STATE
	State: OPEN, OK, NONE,  "Login accepted from tkrmdsdev01.nomura.com:14002"
	AttribInfo
		Name: jitkarr
		NameType: 1 (USER_NAME)
		Attrib
			ELEMENT_LIST
				ELEMENT_ENTRY AllowSuspectData: 1
				ELEMENT_ENTRY ApplicationId: 215
				ELEMENT_ENTRY ApplicationName: ADS
				ELEMENT_ENTRY Position: 10.199.92.165/MUMWD041460
				ELEMENT_ENTRY ProvidePermissionExpressions: 1
				ELEMENT_ENTRY ProvidePermissionProfile: 0
				ELEMENT_ENTRY SingleOpen: 1
				ELEMENT_ENTRY SupportOMMPost: 1
				ELEMENT_ENTRY SupportPauseResume: 0
				ELEMENT_ENTRY SupportStandby: 0
				ELEMENT_ENTRY SupportBatchRequests: 7
				ELEMENT_ENTRY SupportViewRequests: 1
				ELEMENT_ENTRY SupportOptimizedPauseResume: 0
	Payload: None
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
43 3 4 4

@Nipat Kunvutipongsak It did not work.

setting encoding as UTF-8 in gradle script did not work.

Am I making any mistake in encoding login request (please refer the code attached above)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I don't think so because the application can run properly in IDE. However, the problem happened when it's packed into WAR/JNLP.

Upvotes
1.9k 7 10 16

@ramesh.jitkar, can you try adding java-vm-args="-Dfile.encoding=UTF-8" in the jnlp file (a resource section), and replicate the problem again?
Example:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
    <information>
        <title>Dynamic Tree Demo</title>
        <vendor>Dynamic Team</vendor>
        <icon href="sometree-icon.jpg"/>
        <offline-allowed/>
    </information>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.6+" href=
           "http://java.sun.com/products/autodl/j2se"/ java-vm-args="-Dfile.encoding=UTF-8">
        <jar href="DynamicTreeDemo.jar"
            main="true" />

    </resources>
    <application-desc
         name="Dynamic Tree Demo Application"
         main-class="webstartComponentArch.DynamicTreeApplication"
         width="300"
         height="300">
     </application-desc>
     <update check="background"/>
</jnlp>
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
43 3 4 4

@Nipat Kunvutipongsak Hi Nipat, Setting encoding in JNLP also did not work.

But as a random try, I tried setting UTF8_STRING in encoding.

encoder.encodeElementEntryInit(RDMUser.Attrib.ApplicationId, OMMTypes.UTF8_STRING);
encoder.encodeString("215", OMMTypes.UTF8_STRING);
encoder.encodeElementEntryInit(RDMUser.Attrib.Position, OMMTypes.UTF8_STRING);
encoder.encodeString(defaultPosition, OMMTypes.UTF8_STRING);

This change gave successfull login but with still some unreadable charachters and one exception

Feb 21, 2018 10:30:28 AM com.reuters.rfa.internal.connection.rssl.RSSLConnection processTransportData
SEVERE: com.reuters.rfa.connection.rssl.Tiger.RFAFeed
Caught internal exception com.reuters.rfa.omm.OMMException: Actual length is longer than saved length.
  com.reuters.rfa.internal.rwf.RwfEncIter.writeLengthU7(RwfEncIter.java:261)
  com.reuters.rfa.internal.rwf.RwfEncIter.writeLengthU7(RwfEncIter.java:252)
  com.reuters.rfa.internal.rwf.RwfEncIter.writeLength(RwfEncIter.java:136)
  com.reuters.rfa.internal.rwf.RwfEncoder.popIterIfClear(RwfEncoder.java:2682)

However it further fails while sending request for market data updates with below message

MESSAGE
	Msg Type: MsgType.STATUS_RESP
	Msg Model Type: MARKET_PRICE
	Indication Flags: 
	Hint Flags: HAS_ATTRIB_INFO | HAS_STATE
	State: OPEN, SUSPECT, NONE,  "Waiting for service BBG_DEV UP. Item recovery in progress..."
	AttribInfo
		ServiceName: BBG_DEV
		Name: D1833.T
		NameType: 1 (RIC)
	Payload: None

Please note launching from IDE works fine here also.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1.9k 7 10 16

@ramesh.jitkar, I tried to encode a position with non-ASCII attribute as follows:

 String s = null;
 File file = null;
 FileReader fr = null;
 BufferedReader br = null;
	try {
		file = new File("testText.txt");
		fr = new FileReader(file);
		br = new BufferedReader(fr);
		
		s = br.readLine();
	} catch (Exception e) {
		if (br != null) try { br.close(); } catch (IOException e1) { }
		if (fr != null) try { fr.close(); } catch (IOException e1) { }
		if (file != null) file = null;
	}
 
 encoder.encodeString(s, OMMTypes.UTF8_STRING);

Here this is the data in the file named testText.txt

1.1.1.1/ทดสอบภาษาไทย

When I deployed my application to the server with the jnlp file below:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="Test.jnlp">
	<information>
		<title>Jnlp Testing</title>
		<vendor>Nipat Kunvutipongsak</vendor>
		<homepage href="http://localhost:8080/" />
		<description>Testing Testing</description>
	</information>
	<security>
		<all-permissions/>
	</security>
	<resources>
		<j2se version="1.6+" java-vm-args="-Dfile.encoding=UTF-8"/>
		<jar href="StarterConsumer.jar" />
	</resources>
	<application-desc main-class="com.reuters.rfa.example.omm.cons.StarterConsumer" />
</jnlp>

Then, this is the result that I got from running via Java Web Start:

So, you can notice that there are some weird characters in front of/after "1.1.1.1".

Expected Result:

ELEMENT_ENTRY Position: 1.1.1.1/ทดสอบภาษาไทย

Actual Result:

ELEMENT_ENTRY Position: 1.1.1.1/à?à?à?ªà??à?aà? à?²à?©à?²à¹à?à?¢

So, is it possible to "hard code" only ASCII characters in the login request message (e.g. hostname)?

For example:

String defaultPosition = "1.1.1.1/net";

// comment the statement below and use hardcode dummy data instead.
/* try { defaultPosition = InetAddress.getLocalHost().getHostAddress() + "/" +
        InetAddress.getLocalHost().getHostName(); }  catch( Exception e ) {} */

I just want to ensure that this problem relates to non-ASCII characters or not.

Furthermore, RFA document says that a position value type is ASCII_STRING, however, I also tried to use UTF8_STRING, but it can work properly.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
43 3 4 4

@Nipat Kunvutipongsak

I wrote a small java program and bundled it in a war in with JNLP, and deployed on a web server, and I got exact same issue!!!!

However when I downloaded and extracted the war local desktop and launched as a java program (without using webstart) it worked perfectly fine !!

@Nipat, I think if there were unreadable/extra characters in server or user name in your code you could have faced same problem when launching with webstart. Can you try that?

Thus I am sure that it is not related to the gradle.

It seems that it is related to webstart.

For reference below is the Java, and jnlp files that I am testing with

import com.reuters.rfa.common.*;
import com.reuters.rfa.common.Event;
import com.reuters.rfa.common.EventQueue;
import com.reuters.rfa.config.ConfigDb;
import com.reuters.rfa.omm.*;
import com.reuters.rfa.rdm.RDMMsgTypes;
import com.reuters.rfa.rdm.RDMUser;
import com.reuters.rfa.session.Session;
import com.reuters.rfa.session.omm.OMMConsumer;
import com.reuters.rfa.session.omm.OMMItemEvent;
import com.reuters.rfa.session.omm.OMMItemIntSpec;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

/** * Created by jitkarr on 2/26/2018. */public class MyJnlpFrame extends JFrame implements ActionListener, Client
{
Session rfaSession;
EventQueue responseQueue;
OMMConsumer consumer;
OMMPool ommPool;
Handle loginHandle;
private boolean isLoginAccepted;

public MyJnlpFrame()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new FlowLayout());
JButton loginButton = new JButton("Login");
loginButton.addActionListener(this);
getContentPane().add(loginButton);
setSize(300, 400);
setTitle(getClass().getName());
setVisible(true);
}

public static void main(String[] args)
{
new MyJnlpFrame();
}

@Overridepublic void actionPerformed(ActionEvent e)
{
ConfigDb configDb = new ConfigDb();
Context.initialize(configDb);

//String serverList = "tkrmdsdev01";String serverList = "tkrmdsdev01.nomura.com";

String sessionConfigName = "RFAFeed";

configDb.addVariable("Tiger.Sessions."+sessionConfigName+".connectionList", sessionConfigName);
configDb.addVariable("Tiger.Connections."+sessionConfigName+".connectionType", "RSSL");
configDb.addVariable("Tiger.Connections."+sessionConfigName+".serverList", serverList);

rfaSession = com.reuters.rfa.session.Session.acquire( "Tiger::"+sessionConfigName);

if (rfaSession == null)
{
System.out.println("Could not create RFA Session!!! Exiting !!");
System.exit(-1);
}

System.out.println("RFA session created : " + rfaSession);

//ConsumerClient consumerClient = new ConsumerClient(session);responseQueue = EventQueue.create(rfaSession.getName() + "Queue");

OMMItemIntSpec spec = new OMMItemIntSpec();

ommPool = OMMPool.create();

OMMMsg loginRequest = ommPool.acquireMsg();

loginRequest.setMsgType(OMMMsg.MsgType.STREAMING_REQ);
loginRequest.setMsgModelType(RDMMsgTypes.LOGIN);
loginRequest.setAttribInfo(null, "jitkarr", RDMUser.NameType.USER_NAME);

//String defaultPosition = "1.1.1.1/net";String defaultPosition = "10.199.92.165/MUMWD041460";
/*try { defaultPosition = InetAddress.getLocalHost().getHostAddress() + "/" + InetAddress.getLocalHost().getHostName(); } catch( Exception e ) {}*/OMMEncoder encoder = ommPool.acquireEncoder();
encoder.initialize(OMMTypes.MSG, 500);
encoder.encodeMsgInit(loginRequest, OMMTypes.ELEMENT_LIST, OMMTypes.NO_DATA);
encoder.encodeElementListInit(OMMElementList.HAS_STANDARD_DATA, (short)0, (short) 0);
encoder.encodeElementEntryInit(RDMUser.Attrib.ApplicationId, OMMTypes.ASCII_STRING);
encoder.encodeString("215", OMMTypes.ASCII_STRING);
encoder.encodeElementEntryInit(RDMUser.Attrib.Position, OMMTypes.ASCII_STRING);
encoder.encodeString(defaultPosition, OMMTypes.ASCII_STRING);
encoder.encodeAggregateComplete();

loginRequest = (OMMMsg)encoder.getEncodedObject();
byte[] temp = loginRequest.getBytes();
System.out.println("start login request");
for (int idx = 0; idx < temp.length; idx++) {
System.out.print((char)temp[idx]);
}
System.out.println("end login request");

spec.setMsg(loginRequest);

consumer = (OMMConsumer) rfaSession.createEventSource(EventSource.OMM_CONSUMER, "Consumer", false);

loginHandle = consumer.registerClient(responseQueue, spec, this, null);

MyDispatcher responseDispatcher = new MyDispatcher(this, rfaSession.getName(), responseQueue);
ommPool.releaseEncoder(encoder);

responseDispatcher.start();

System.out.println("Sending Login request....................................................");

//GenericOMMParser.parseMsg(loginRequest, System.out); //////////////////////////////////}

@Overridepublic void processEvent(Event event) {

OMMMsg msg = ((OMMItemEvent)event).getMsg();

//Process Login.if ((msg.getMsgType() == OMMMsg.MsgType.STATUS_RESP) &&
(msg.has(OMMMsg.HAS_STATE)) &&
(msg.getMsgModelType() == RDMMsgTypes.LOGIN) &&
(msg.getState().getStreamState() == OMMState.Stream.OPEN) &&
(msg.getState().getDataState() == OMMState.Data.OK) &&
msg.getState().getText().contains("Login accepted"))
{
//Todo : Should we expect abrupt login disconnected?processLogin(msg);
}
else{
System.out.println("---------------------------------------------");
System.out.println("UnHandled message in login client");
GenericOMMParser.parse(msg);
System.out.println("---------------------------------------------");
}
}

private void processLogin(OMMMsg msg)
{
GenericOMMParser.parse(msg);
System.out.println("LOGIN SUCCESSFULL!!!!!");
isLoginAccepted = true;
}

public class MyDispatcher extends Thread
{
private EventQueue eventQueue;

public MyDispatcher(Client client, String name, EventQueue eventQueue)
{
setName("App ResponseQ Dispatcher-"+name);

this.eventQueue = eventQueue;
}

public synchronized void run()
{
while (true)
{
try{
eventQueue.dispatch(Dispatchable.INFINITE_WAIT);
}
catch (DispatchException de )
{
System.out.println("Queue deactivated");
break;
}
}
System.out.println("Dispatcher terminated...");
}
}
}

<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://jfarm-tiger-tk-uat-jb.nomura.com/jnlpStudy/"
      href="MyJnlp.jnlp">
    <information>
        <title>Ramesh's Sample jnlp app</title>
        <homepage href="index.html"/>
        <vendor>Nomura</vendor>
        <description>Nomura market access and cash trading</description>
        <description kind="short">Nomura Equities market access and single order trading </description>
        <description kind="tooltip">Nomura Equities market access and single order trading </description>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <property name="sun.java2d.noddraw" value="true"/>
        <j2se version="1.6.0_20+" href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="JnlpStudy.jar" />
        <jar href="rfa.jar" />
    </resources>
    <application-desc main-class="MyJnlpFrame">
    </application-desc>
</jnlp>
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.