Page 2 of 2 FirstFirst 12
Results 11 to 20 of 24

Hybrid View

  1. #1
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Could you add a very simple log to file in your adapters? Just to understand what is going on.

  2. #2
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Hello,
    Finally find out the issue, I have modified my shell script as like below,
    cpath="/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/ls-adapter-remote.jar:/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/jedis.jar:/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/gson.jar:/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/LS_quote_feed_simulator.jar"
    class="stocklist.server.ServerMain"


    command="java -cp $cpath $class -host localhost -metadata_rrport 6722 -data_rrport 6720 -data_notifport 6721"
    exec $command $
    It seems need to give values within double quote.

    Now I have an issue on getting update from redis and serve this data to subscribed items.
    I have used redis instance on ExternalFeedSimulator java class. Can you please on this where I need to create instance and where to close the redis exactly. Because of this I'm facing the issue like
    Exception in thread "Timer-0" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 12
    My code looks like below,
    import com.google.gson.Gson;
    import com.google.gson.annotations.SerializedName;
    import redis.clients.jedis.Jedis;

    public class ExternalFeedSimulator {
    private static Jedis jedis;
    private static final String redisHost = "localhost";
    private static final Integer redisPort = 6379;
    private static Gson gson = new Gson();

    public void start() {
    try {
    jedis = new Jedis(redisHost, redisPort);
    getJSON();
    long waitTime = 500;
    bidaskratescheduleGenerator(bidaskrates, waitTime);
    } catch (Exception e) { System.out.println(e);
    }
    }

    public static String getJSON() {
    try {
    liveratesnew.clear(); ClientsRateRow[] craterows = gson.fromJson(jedis.get("WLallclientsrates"), ClientsRateRow[].class);
    for (ClientsRateRow raterow : craterows) {
    liveratesnew.put(raterow.client_com_id, raterow);
    curclientrates.add(raterow);
    }
    RateRow[] cbaserates = gson.fromJson(jedis.get("WLBaseRates"), RateRow[].class);
    for (RateRow raterow : cbaserates) {
    bidaskrates.add(raterow);
    }
    } catch (IllegalStateException ex) {
    ex.printStackTrace();
    } finally {
    jedis.close();
    }
    return null;


    }

    private void bidaskratescheduleGenerator(final ArrayList<RateRow> displayrates, long waitTime) {
    dispatcher.schedule(new TimerTask() {
    @Override
    public void run() {
    long nextWaitTime;
    synchronized (displayrates) {
    if (listener != null) {
    for (RateRow curbidaskrates : displayrates) {
    final HashMap<String, String> bidaskevent = new HashMap<String, String>();
    bidaskevent.put("desc", curbidaskrates.getGold1_symbol());
    bidaskevent.put("bid", curbidaskrates.getGold1_bid());
    bidaskevent.put("ask", curbidaskrates.getGold1_ask());
    bidaskevent.put("high", curbidaskrates.getGold1_high());
    bidaskevent.put("low", curbidaskrates.getGold1_low());
    bidaskevent.put("ltp", curbidaskrates.getGold1_ltp());
    listener.onEvent(curbidaskrates.getGold1_symbol(), bidaskevent, false);
    }
    }
    displayrates.clear();
    nextWaitTime = 500;
    }
    getJSON();
    bidaskratescheduleGenerator(bidaskrates, nextWaitTime);
    }
    }, waitTime);
    }


    }
    In my php service every second will update the stock market rates into redis key as json string. In my java adapter for every 500 milliseconds i need to read and update to subscribed clients. Could you please help me on this how to do this in my adapter.
    Last edited by rvkvino; July 8th, 2020 at 07:49 AM.

  3. #3
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi,

    The error message seems not pertaining to redis but to the json parser.
    Please have a look at this https://stackoverflow.com/questions/...ine-1-column-1, maybe can help with your issue.

    Regards,
    Giuseppe

  4. #4
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    I have referred this link already,
    My actual issue comes like this first time after that only I'm facing issue on json string. If I handle this issue the above json issue not comes.

    redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Connection reset by peer: socket write error
    at redis.clients.jedis.Connection.flush(Connection.java:334)
    at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:257)
    at redis.clients.jedis.Connection.getBulkReply(Connection.java:248)
    at redis.clients.jedis.Jedis.get(Jedis.java:153)
    at stocklist.feed_simulator.ExternalFeedSimulator.getJSON(ExternalFeedSimulator.java:78)
    at stocklist.feed_simulator.ExternalFeedSimulator$1.run(ExternalFeedSimulator.java:128)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)
    Caused by: java.net.SocketException: Connection reset by peer: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at redis.clients.util.RedisOutputStream.flushBuffer(RedisOutputStream.java:52)
    at redis.clients.util.RedisOutputStream.flush(RedisOutputStream.java:216)
    at redis.clients.jedis.Connection.flush(Connection.java:331)
    .
    my json looks like this only
    [
    {
    "com_id": "33",
    "com_name": "GOLD BAR",
    "selling_rate": "5001",
    "buying_rate": "-",
    "delivery": "03-07-2020",
    "retail_rate": "-",
    "com_weight": "1.000",
    "com_order": "1",
    "client": "lmxtrade",
    "client_com_id": "lmxtrade_33",
    "high_rate": "5002",
    "low_rate": "4980"
    },
    {
    "com_id": "36",
    "com_name": "GOLD FT",
    "selling_rate": "5001",
    "buying_rate": "4800",
    "delivery": "03-07-2020",
    "retail_rate": "-",
    "com_weight": "1.000",
    "com_order": "2",
    "client": "lmxtrade",
    "client_com_id": "lmxtrade_36",
    "high_rate": "5002",
    "low_rate": "4980"
    },
    {
    "com_id": "37",
    "com_name": "GOLD RTGS",
    "selling_rate": "4901",
    "buying_rate": "-",
    "delivery": "03-07-2020",
    "retail_rate": "-",
    "com_weight": "1.000",
    "com_order": "3",
    "client": "lmxtrade",
    "client_com_id": "lmxtrade_37",
    "high_rate": "4902",
    "low_rate": "4880"
    },
    {
    "com_id": "38",
    "com_name": "SILVER",
    "selling_rate": "49190",
    "buying_rate": "48463",
    "delivery": "03-07-2020",
    "retail_rate": "-",
    "com_weight": "1000.000",
    "com_order": "4",
    "client": "lmxtrade",
    "client_com_id": "lmxtrade_38",
    "high_rate": "49190",
    "low_rate": "49190"
    },
    {
    "com_id": "33",
    "com_name": "GOLD CBE RTGS ",
    "selling_rate": "5001",
    "buying_rate": "4890",
    "delivery": "07-07-2020",
    "retail_rate": "-",
    "com_weight": "1.000",
    "com_order": "1",
    "client": "kkvtrade",
    "client_com_id": "kkvtrade_33",
    "high_rate": "5002",
    "low_rate": "4980"
    },
    {
    "com_id": "36",
    "com_name": "GOLD FT",
    "selling_rate": "5001",
    "buying_rate": "4900",
    "delivery": "07-07-2020",
    "retail_rate": "-",
    "com_weight": "1.000",
    "com_order": "2",
    "client": "kkvtrade",
    "client_com_id": "kkvtrade_36",
    "high_rate": "5002",
    "low_rate": "4980"
    },
    {
    "com_id": "37",
    "com_name": "GOLD RTGS",
    "selling_rate": "4901",
    "buying_rate": "5000",
    "delivery": "07-07-2020",
    "retail_rate": "-",
    "com_weight": "1.000",
    "com_order": "3",
    "client": "kkvtrade",
    "client_com_id": "kkvtrade_37",
    "high_rate": "4902",
    "low_rate": "4880"
    },
    {
    "com_id": "38",
    "com_name": "SILVER",
    "selling_rate": "50369",
    "buying_rate": "50354",
    "delivery": "07-07-2020",
    "retail_rate": "-",
    "com_weight": "1000.000",
    "com_order": "4",
    "client": "kkvtrade",
    "client_com_id": "kkvtrade_38",
    "high_rate": "50400",
    "low_rate": "50008"
    }
    ]
    This above json i'm parsing using the class,(Array of object)
    ClientsRateRow[] craterows = gson.fromJson(jedis.get("WLallclientsrates"), ClientsRateRow[].class);
    Last edited by rvkvino; July 8th, 2020 at 09:32 AM.

  5. #5
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Have you tried to approach all redis operations in the getJSON method (open the connection, retrieve the json and close)?

  6. #6
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Yes this helped me. I have open and close all the places wherever I have used Redis and then closed. Now working fine my adapter. My problem is solved in website. Now I need to know whether is there any LS client library is available for dart language. I'm developing app in Flutter, now I need to show market rates in app also which I done in website.

 

 

Similar Threads

  1. Replies: 12
    Last Post: May 26th, 2014, 09:59 AM
  2. Error handling for: [Unexpected update for item]
    By tony99nyr in forum Adapter SDKs
    Replies: 3
    Last Post: April 7th, 2014, 09:29 AM
  3. Preventing user access after notifyUser call
    By sarbao in forum Adapter SDKs
    Replies: 2
    Last Post: March 3rd, 2014, 07:39 AM
  4. NotifyUser Header
    By milad.j in forum Adapter SDKs
    Replies: 1
    Last Post: November 4th, 2013, 09:23 AM
  5. Delay in notifyUser() causes erratic create_session behavior
    By brianjohnson in forum Adapter SDKs
    Replies: 2
    Last Post: April 5th, 2010, 12:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 05:50 AM.