Data Not Being Inserted


#1

I am using the basic example from the site;
https://github.com/realm/realm-server-side-samples/blob/master/13-loading-sample-data/loader.js

I played with it couple weeks ago, and I managed to succesfully view the insterted data in Realm Studio…

However, I went back yesterday and tried to same code, nothing seems to get inserted. Using node.js;

const faker = require(‘faker’)
const Realm = require(‘realm’)
const fs = require(‘fs’)

var totalTickers = 100

//insert the your connection information
const URL = ‘tickertest.us1a.cloud.realm.io’;
const username = ‘[email protected]’;
const password = ‘1234’;
var tickerRealmPath = “/tickers”

const TickerSchema = {
name: ‘Ticker’,
properties: {
‘tickerSymbol’: { type: ‘string’, optional: false, default: ‘’ },
‘price’: { type: ‘float’, optional: false, default: 0 },
‘companyName’: { type: ‘string’, optional: false, default: ‘’ }
}
}

//generates random data to be inserted
function generateRandomTickerSymbol(len) {
charSet = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’;
let randomString = ‘’;
for (let i = 0; i < len; i++) {
let randomPoz = Math.floor(Math.random() * charSet.length);
randomString += charSet.substring(randomPoz, randomPoz + 1);
}
return randomString;
}

const errorCallback = function errorCallback(message, isFatal, category, code) {
console.log(Message: ${message} - isFatal: ${isFatal} - category: ${category} - code: ${code})
}

Realm.Sync.User.login(https://${URL}, username, password)
.then((user) => {
Realm.open({
sync: {
url: realms://${URL}${tickerRealmPath},
user: user,
error: errorCallback,
partial: true
},
schema: [TickerSchema],
})
.then((realm) => {
let tickerResults = realm.objects(‘Ticker’);
if (tickerResults.length < totalTickers) {
//write to the realm
realm.write(() => {
for (let index = 0; index < totalTickers; index++) {
realm.create(‘Ticker’, {
tickerSymbol: generateRandomTickerSymbol(3),
price: index,
companyName: faker.company.companyName()
}, true)
}
})
}
realm.close()
})
});

There is nothing in the logs that throws an error, but I can not view any of the tickers.


#2

After putting some logging, it seems like it never goes into the section after
.then((realm) =>

So for some reason, it doesn’t seem like it is opening although it creates the /tickers path… What am I missing?


#3

@testingRealm If you add Realm.Sync.setLogLevel('debug'); at the top it should give you more detailed output and logs to tell what is happening but if I believe this is older code that has not been updated yet. You can remove the partial: true parameter in the realm.open call - also make sure you are using an admin user with [email protected]


#4

@ianward
Thank you for your response. I have removed the partial: true and added the debug line… But doesn’t seem to throw any exceptions…

User.login is deprecated. Please use User.login(server, Credentials.usernamePassword(…)) instead.
Realm sync client ([realm-core-5.12.1], [realm-sync-3.13.4], protocol version 25)
Platform: Windows Win32 unknown 10.0.17134.1 x86
Build mode: Release
Config param: max_open_files = 256
Config param: one_connection_per_session = 1
Config param: connect_timeout = 600000 ms
Config param: connection_linger_time = 30000 ms
Config param: ping_keepalive_period = 600000 ms
Config param: pong_keepalive_timeout = 600000 ms
Config param: fast_reconnect_limit = 60000 ms
Config param: enable_upload_log_compaction = 1
Config param: tcp_no_delay = 0
User agent string: ‘RealmSync/3.13.4 (Windows Win32 unknown 10.0.17134.1 x86)’
Connection[1]: WebSocket::Websocket()
Connection[1]: Session[1]: Binding ‘C:\roivant\roivant-realm-poc\realm-object-server\3c72c72b-92be-44c6-abb1-69147ff2a293\realms%3A%2F%2Ftickertest.us1a.cloud.realm.io%2Ftickers’ to ‘/tickers’
Connection[1]: Session[1]: Activating
Opening Realm file: C:\roivant\roivant-realm-poc\realm-object-server\3c72c72b-92be-44c6-abb1-69147ff2a293\realms%3A%2F%2Ftickertest.us1a.cloud.realm.io%2Ftickers
Connection[1]: Session[1]: Progress handler called, downloaded = 0, downloadable = 0, uploaded = 0, uploadable = 0, progress version = 0, snapshot version = 1
Connection[1]: Resolving ‘tickertest.us1a.cloud.realm.io:443
Connection[1]: Connecting to endpoint ‘54.201.68.114:443’ (1/3)
Connection[1]: Connected to endpoint ‘54.201.68.114:443’ (from ‘127.0.0.1:62780’)
Connection[1]: Verifying server SSL certificate using root certificates, host name = tickertest.us1a.cloud.realm.io, server port = 443, certificate =
-----BEGIN CERTIFICATE-----
MIIEdTCCA12gAwIBAgIJAKcOSkw0grd/MA0GCSqGSIb3DQEBCwUAMGgxCzAJBgNV
BAYTAlVTMSUwIwYDVQQKExxTd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VHSAECjAIMAYG
BFUdIAAwDQYJKoZIhvcNAQELBQADggEBACMd44pXyn3pF3lM8R5V/cxTbj5HD9/G
VfKyBDbtgB9TxF00KGu+x1X8Z+rLP3+QsjPNG1gQggL4+C/1E2DUBc7xgQjB3ad1
l08YuW3e95ORCLp+QCztweq7dp4zBncdDQh/U90bZKuCJ/Fp1U1ervShw3WnWEQt
8jxwmKy6abaVd38PMV4s/KCHOkdp8Hlf9BRUpJVeEXgSYCfOn8J3/yNTd126/+pZ
59vPr5KW7ySaNRB6nJHGDn2Z9j8Z3/VyVOEVqQdZe4O/Ui5GjLIAZHYcSNPYeehu
VsyuLAOQ1xk4meTKCRlb/weWsKh/NEnfVqn3sF/tM+2MR7cwA130A4w=
-----END CERTIFICATE-----

Connection[1]: Verifying server SSL certificate using 155 root certificates
Connection[1]: Server SSL certificate verified using root certificate(29):
-----BEGIN CERTIFICATE-----
MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UE
ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENs
YXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5
MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2ll
cywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRo
b3JpdHkwggEgMA0GCSqGSIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N
78gDGIc/oav7PKaf8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMe
j2YcOadN+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0
X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4Umkhyn
ArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W
93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRb
Vazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0fhvRbVazc1xDCDqmI56FspGowaDEL
MAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAw
BgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1ep
oXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D
eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJlxy16paq8
U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJDKVtH
CN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
QBFGmh95DmK/D5fs4C8fF5Q=
-----END CERTIFICATE-----

  • You mentioned, it is an old code… I can not seem to find it, is there any new code that I can find just to test inserting data to cloud…

#5

@testingRealm There’s your issue - your Realm type is full but you need it to be reference. Press the upgrade button in Studio after selecting the Realm


#6

@ianward Thanks but I tried too… Still no data unfortunately.


#7

@testingRealm What do the logs say on the server? What do the logs say on the node client?


#8

@ianward


#9

@testingRealm can you wipe the local state of node client and reconnect please

rm -rf realm-object-server


#10

@ianward … still no data;


#11

What version of realm-js are you on? The logs show that you are creating a full type realm even though it should default to partial sync - please attach the client side logs as well