How to use the node-opcua-service-subscription.PublishRequest function in node-opcua-service-subscription

To help you get started, we’ve selected a few node-opcua-service-subscription examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-server / test_to_fix / test_subscriptions.js View on Github external
it("server should handle Publish request", function (done) {

        // publish request now requires a subscriptions
        var request = new subscription_service.PublishRequest({
            subscriptionAcknowledgements: []
        });
        g_session.publish(request, function (err, response) {

            if (!err) {
                response.should.be.instanceof(subscription_service.PublishResponse);

                response.should.have.ownProperty("subscriptionId");          // IntegerId
                response.should.have.ownProperty("availableSequenceNumbers");// Array,Counter,
                response.should.have.ownProperty("moreNotifications");       // Boolean
                response.should.have.ownProperty("notificationMessage");
                response.should.have.ownProperty("results");
                response.should.have.ownProperty("diagnosticInfos");
            }
            done(err);
        });
github node-opcua / node-opcua / packages / node-opcua-client / source / private / client_publish_engine.ts View on Github external
//
        // see https://github.com/node-opcua/node-opcua/issues/141
        // This suitable value shall be at least the time between two keep alive signal that the server will send.
        // (i.e revisedLifetimeCount * revisedPublishingInterval)

        // also ( part 3 - Release 1.03 page 140)
        // The Server shall check the timeoutHint parameter of a PublishRequest before processing a PublishResponse.
        // If the request timed out, a Bad_Timeout Service result is sent and another PublishRequest is used.
        // The value of 0 indicates no timeout

        // in our case:

        assert(this.nbPendingPublishRequests > 0);
        const calculatedTimeout = this.nbPendingPublishRequests * this.timeoutHint;

        const publishRequest = new PublishRequest({
            requestHeader: {timeoutHint: calculatedTimeout}, // see note
            subscriptionAcknowledgements
        });

        let active = true;

        const session = this.session! as ClientSessionImpl;
        session.publish(publishRequest, (err: Error | null, response?: PublishResponse) => {

            this.nbPendingPublishRequests -= 1;

            if (err) {
                debugLog(chalk.cyan("ClientSidePublishEngine.prototype._send_publish_request callback : "),
                    chalk.yellow(err.message));
                debugLog("'" + err.message + "'");
github node-opcua / node-opcua / packages / node-opcua-client / src / client_publish_engine.js View on Github external
//
    // see https://github.com/node-opcua/node-opcua/issues/141
    // This suitable value shall be at least the time between two keep alive signal that the server will send.
    // (i.e revisedLifetimeCount * revisedPublishingInterval)

    // also ( part 3 - Release 1.03 page 140)
    // The Server shall check the timeoutHint parameter of a PublishRequest before processing a PublishResponse.
    // If the request timed out, a Bad_Timeout Service result is sent and another PublishRequest is used.
    // The value of 0 indicates no timeout

    // in our case:

    assert( self.nbPendingPublishRequests >0);
    const calculatedTimeout = self.nbPendingPublishRequests * self.timeoutHint;

    const publish_request = new subscription_service.PublishRequest({
        requestHeader: {timeoutHint: calculatedTimeout}, // see note
        subscriptionAcknowledgements: subscriptionAcknowledgements
    });

    let active = true;

    self.session.publish(publish_request, function (err, response) {

        self.nbPendingPublishRequests -= 1;
        if (err) {
            debugLog("ClientSidePublishEngine.prototype._send_publish_request callback : ".cyan, err.message.yellow);
            debugLog("'" + err.message + "'");

            if(err.message.match("not connected")) {
                debugLog(" WARNING :  CLIENT IS NOT CONNECTED : MAY BE RECONNECTION IS IN PROGRESS".bgWhite.red);
                debugLog("self.activeSubscriptionCount =",self.activeSubscriptionCount);