-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - How to use "logout/close" to run a api call every 5 sec. #19
Comments
You need to reuse the connection save it to a variable. E.g. only call the function with login credentials once. Another repo but line 30 shows running the logout function. |
This code you should be able to run over and over again without hitting the routers limit of 5 active sessions due to the logout at the end. const huaweiLteApi = require('huawei-lte-api')
// Varible globaly scoped
let connection
async function sendSMS(inputText) {
try {
connection = new huaweiLteApi.Connection('http://admin:[email protected]/')
await connection.ready
// Phone number must be an array of strings
const resultSendSMS = await new huaweiLteApi.Sms(connection).sendSms(['12345678'], inputText)
console.log('result for send SMS =', resultSendSMS)
} catch (error) {
console.error('Ended in error:')
console.error(error)
} finally {
// finallyCode - Code block to be executed regardless of the try result
const resultLogout = await new huaweiLteApi.User(connection).logout()
console.log('result from logout=',resultLogout)
connection = null
}
}
sendSMS('My message to send') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let's take ref. in you example/device_info.js.
If i execute that every 5 sec. after 4 or 5 times I get a
ResponseErrorException: 108003: Already login
Just used this one for test, but if that one is not working, then the ones I want to use will neither.
Believe there must be a way to close connection/logout or something like that, but I don't know how to program that.
What I am after is a way to receive SMS's, but for that I need to "check" every X sec.
I have the flow and nodes in place, but it's not bulletproff.
I check every 10 sec. (but want to go lower) if there is new sms, I save that one in a folder, then I monitor that folder, and gets the information in sms, and then call the delete function
I'm trying to get it to work in the Node-red package, but must be sure that it works in the API, before taking it further.
The text was updated successfully, but these errors were encountered: