Closed mustafaibrahim989 closed 7 years ago
Hi, Are you running the code against a local intallation of Lightstreamer Server? That would be ideal, because we could see on the Server log how your changes affect the interaction with the Server. In that case, also set LightstreamerLogger.pump at DEBUG level in lightstreamer_log_conf.xml.
Otherwise, please specify all the changes you made to the original code, or show us the entire code.
-- Dario Crivelli Computer Scientist
Lightstreamer | www.lightstreamer.com
email: dario.crivelli@lightstreamer.com
Lightstreamer is the leading solution for real-time messaging and data streaming. Power mobile, web, and IoT apps.
On Mon, May 8, 2017 at 12:08 AM, Mustafa Ibrahim notifications@github.com wrote:
Hello, I am trying the following code on index.android.js and It do logs "SUBSCRIBED" with no way to got onItemUpdate called. the same code is working fine with index.ios.js
subscription.addListener({ onSubscription: function() { console.log('SUBSCRIBED'); }, onUnsubscription: function() { console.log('UNSUBSCRIBED'); }, onItemUpdate: function(obj) { console.log("item update: " + obj.getItemName()) } });
Thanks for your help
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-reactnative/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWaDZjL_8LL0AEw58S_pnshghiPurpFks5r3kDlgaJpZM4NTUdW .
Unfortunately, I am using a remote LS server. So I will share the code snippet with you.
const that = this; var lsClient = new ls.LightstreamerClient(); lsClient.connectionDetails.setServerAddress(SERVER_URL); lsClient.connectionDetails.setUser(CONNECTION_STRING); lsClient.connectionDetails.setPassword(PASSWORD); lsClient.connectionDetails.setAdapterSet(subscriptionProxy); lsClient.connect(); var subscription = new ls.Subscription(subscriptionCommand, [ITEM_1, ITEM_2, ITEM_3], subscriptionFields); subscription.setDataAdapter(subscriptionProxy); subscription.setRequestedSnapshot('yes'); lsClient.subscribe(subscription); lsClient.addListener({ onStatusChange: function(newStatus) { console.log("newStatus: " + newStatus); } }); subscription.addListener({ onSubscription: function() { console.log('SUBSCRIBED'); }, onUnsubscription: function() { console.log('UNSUBSCRIBED'); }, onItemUpdate: function(obj) { console.log("item update: " + obj.getItemName()) } });
Is the remote LS Server in use our demo Server at push.lightstreamer.com (as in the original demo) or a third party one? I couldn't identify your requests in the push.lightstreamer.com Server log.
For a subscription to succeed but then yield no data, it is enough that the item names or field names are wrong. But this depends on the specific Server installation; if it is a third-party one, we at Lightstreamer cannot help you.
Obviously, if the same code behaves successfully on iOS and not on Android, this is unexpected. I suppose that there is some sneaky difference in your code, but we cannot delve at that level of investigation with the available information.
So, if you are using a third-party Server, please try to replicate the behavior connecting to push.lightstreamer.com and using the proper item and field names, as shown by the original demo. To make your requests easy to detect in the log, you could use some nonempty user name.
BTW, I note that you use the same variable (subscriptionProxy) for both Adapter Set and Data Adapter name. This is strange, though possible. Do you confirm that this exact code invokes onSubscription?
-- Dario Crivelli Computer Scientist
Lightstreamer | www.lightstreamer.com
email: dario.crivelli@lightstreamer.com
Lightstreamer is the leading solution for real-time messaging and data streaming. Power mobile, web, and IoT apps.
Hi all,
I'm having same issue. My server is Lightstreamer 7.0.0 b1.
My ReactNative Lightstreamer client version is 7.0.7.
I didn't try iOS but I used web client and everything worked, but on Android I don't get updates.
Here is my code:
`try { this.lsClient = new ls.LightstreamerClient("http://myserver.com", "AAA");
this.lsClient.addListener({
onStatusChange: function (newStatus) {
console.log("STATUS_CHANGED - MATCH");
console.log(JSON.stringify(newStatus));
}
});
this.lsClient.connect();
this.testSubscription = new ls.Subscription("DISTINCT", "match_123", ["event"]);
this.testSubscription.setDataAdapter("BBB");
this.testSubscription.setRequestedSnapshot("yes");
this.testSubscription.addListener({
onSubscription: () => {
console.log("*~* SUBSCRIBED - MATCH");
},
onUnsubscription: () => {
console.log("*~*UNSUBSCRIBED - MATCH");
},
onItemUpdate: (obj) => {
console.log("*~*CHANGED !!!!!!!!!!!! - MATCH");
console.log(JSON.stringify(obj));
}
});
this.lsClient.subscribe(this.testSubscription);
} catch (error) {
console.log('====================================');
console.log(error);
console.log('====================================');
}`
and I manage to connect and to subscribe, but I don't get any updates. And updates are sent for sure because I have web client that use same server.
Here is log that I get for code above:
`08-24 14:12:02.318 31574 31932 I ReactNativeJS: STATUS_CHANGED - MATCH
08-24 14:12:02.318 31574 31932 I ReactNativeJS: "CONNECTING"
08-24 14:12:08.883 31574 31932 I ReactNativeJS: STATUS_CHANGED - MATCH
08-24 14:12:08.883 31574 31932 I ReactNativeJS: "DISCONNECTED:WILL-RETRY"
08-24 14:12:08.906 31574 31932 I ReactNativeJS: STATUS_CHANGED - MATCH
08-24 14:12:08.906 31574 31932 I ReactNativeJS: "CONNECTING"
08-24 14:12:09.858 31574 31932 I ReactNativeJS: STATUS_CHANGED - MATCH
08-24 14:12:09.858 31574 31932 I ReactNativeJS: "CONNECTED:STREAM-SENSING"
08-24 14:12:10.445 31574 31932 I ReactNativeJS: STATUS_CHANGED - MATCH
08-24 14:12:10.445 31574 31932 I ReactNativeJS: "CONNECTED:WS-STREAMING"
08-24 14:12:10.672 31574 31932 I ReactNativeJS: ~ SUBSCRIBED - MATCH`
And it stays like this until I call unsubscribe and disconnect: 08-24 14:12:10.672 31574 31932 I ReactNativeJS: ~ SUBSCRIBED - MATCH
08-24 14:18:00.477 31574 31932 I ReactNativeJS: ~UNSUBSCRIBED - MATCH
08-24 14:18:00.502 31574 31932 I ReactNativeJS: STATUS_CHANGED - MATCH
08-24 14:18:00.502 31574 31932 I ReactNativeJS: "DISCONNECTED" `
Any ideas?
Thanks.
Kind regards, Stefan
Hello Stefan, Since you are using Server version 7.0.0 b1, I guess that you are running a local installation of the Server. So, it is easy for you to collect Server log. Please show us the Server log in both the successful and the unsuccessful case, after configuring the Server log with the LightstreamerLogger.subscriptions and LightstreamerLogger.pump loggers at DEBUG level.
Hi Dario,
thanks for fast replay and sorry I took some time to answer. Here are server logs when I subscribe with android and with web client.
Hope you see something useful in them. android.txt web.txt
Kind regards, Stefan
The Server seems completely unaware of the client problems. It receives a first session request and answers to it, but the client seems to ignore the response. Then a second attempt, which seems identical, succeeds. On this session, the subscription succeeds and the Server sends the notification of the subscription, then some updates, then the notification of the unsubscription; but it seems that the initial and final notifications are logged, whereas the updates in the middle are not.
Is it possible that some error message was not detected? You can have LS library log its own errors on console by adding the following lines (with the required Requires) at the beginning:
var loggerProvider = new SimpleLoggerProvider();
var myAppender = new ConsoleAppender("ERROR","*");
loggerProvider.addLoggerAppender(myAppender);
LightstreamerClient.setLoggerProvider(loggerProvider);
I added your code and didn't notice any changes in log. Are you sure this logging works with reactnative on Android (I'm monitoring both server log and android log)?
I tried connecting web client and Android (react-native) client at same time to same LS server, and I still have same behavior, both clients connect and subscribe, but just web client gets updates. After closing, both clients unsubscribe and disconnect.
I noticed one more thing once you wrote it above. We always first get "DISCONNECTED:WILL-RETRY", then "CONNECTING" then "CONNECTED:STREAM-SENSING" then "CONNECTED:WS-STREAMING".
For me, it's very odd that we never connect on first try. Maybe that causes the issue?
The initial failure in establishing a session is really strange: the Server answers correctly, but the client seems not to see the answer. However, the underlying http layer can see the answer, because it reuses the same socket when the client issues the second attempt.
As far as LS library is concerned, the first failure cannot impact on the behavior of the second attempt. More likely, the underlying problem still to be identified may cause both issues. Some undetected exception in the client could have been an explanation.
By the way, I was imprecise when I sent you the logging instruction, as I took the syntax usually used for the Web SDK. Here, with the Node.js sdk, the syntax should be adapted a bit, to become:
var ls = require('lightstreamer-client');
var loggerProvider = new ls.SimpleLoggerProvider();
var myAppender = new ls.ConsoleAppender("ERROR","*");
loggerProvider.addLoggerAppender(myAppender);
ls.LightstreamerClient.setLoggerProvider(loggerProvider);
I apologize and hope you already managed to fix that.
As far as we know, the library log should work in react-native on android. But, just to test it, you can change ERROR to INFO or DEBUG. Actually, if you can't see anything at ERROR level, please send us the log at DEBUG level.
Hi,
I tried this code and still got nothing. I changed to debug and got something. Here is debug-log ls-debug.txt
Thanks for your time.
Kind regards, Stefan
EDIT: I noticed in log: d(1,1,'#','#','#','#','#','#','#','#','#','#','29:16');
this is data that is sent from server, so I do get it but onItemUpdate didn't run.
Hi Stefan,
Yes, it seems that the update is received; yet, it is ignored internally with no visible sign. This resembles a known issue that occurs in some scenarios, which we initially ruled out because in our tests it always would produce error messages. The matter is a bit tricky. If you don't mind, please continue by emailing us to support@lightstreamer.com
Thanks to Stefan the issue was sorted out. It is a compatibility issue that originates in the Server. The problem affects both Server version 6.1.0 and the recent 7.0.0 b1.
For 6.1.0 there is a patch (6.1.0 build 1817.7) available here.
For 7.0.0 b1 there is currently no patch available. The final version of Server 7.0.0, obviously, will include the fix. Until the 7.0.0 release, we suggest sticking to Server 6.1.0 and using build 1817.7. In fact, 7.0.0 b1 is very similar to 6.1.0, as only the license configuration is different.
Hello, I am trying the following code on
index.android.js
and It does logs "SUBSCRIBED" with no way to gotonItemUpdate
called. the same code is working fine withindex.ios.js
subscription.addListener({ onSubscription: function() { console.log('SUBSCRIBED'); }, onUnsubscription: function() { console.log('UNSUBSCRIBED'); }, onItemUpdate: function(obj) { console.log("item update: " + obj.getItemName()) } });
Thanks for your help