Troubleshoot middleware API failures

Most middleware APIs return an SdvResult object. On success, this object contains the expected result object. On failure, this object contains an SdvStatus object, indicating an unexpected behavior or error condition, often identified by an error code, such as Internal, Unavailable, or DataLoss.

This page helps you troubleshoot these error codes.

Troubleshoot registration and creation failures

Registration and creation failures typically arise when you are trying to create or register an invalid service.

Can't create second service

Error:

Internal error.

Cause:

You're attempting to register the exact same service bundle instance (name and instance ID) twice.

Fix:

Don't attempt to register the exact same service bundle instance (name and instance ID) twice.

Can't delete duplicate service bundle

Error:

Status(-3, EX_ILLEGAL_ARGUMENT)

Cause:

You're attempting to delete a duplicate service bundle that doesn't exist.

Fix:

Don't attempt to delete a duplicate service bundle that doesn't exist.

Can't retrieve a publisher instance for sending messages

Error:

Call to take_publisher() returns none.

Cause:

You called take_publisher() twice for the same variant from the same service bundle instance.

Fix:

Don't call take_publisher() twice for the same variant from the same service bundle instance.

Can't create a Subscriber, Observer, History, or InstantReader

Error:

Unavailable error.

Cause:

You tried to create a Subscriber, Observer, History, or InstantReader for a publisher that doesn't exist or that has been deregistered.

Fix:

Verify that the publisher exists or is registered before trying to create a Subscriber, Observer, History, or InstantReader for the publisher.

Can't create RPC client

Error:

Unavailable error

Cause:

You tried to create a create an RPC client for a server unit name that doesn't exist or isn't registered.

Fix:

Verify that the server exists and is registered before creating the RPC client.

Troubleshoot communication failures

Communication failures might occur after a service has excuted and begins to communicate with other services.

Troubleshoot publisher deregistration

Errors can occur when a publisher deregisters while its readers are still active.

Subscriber's read_next_messages() returns empty lists

Error:

read_next_messages() succeeds but returns empty lists.

Cause:

The publisher is deregistered while its readers are active.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is unavailable, then the publisher is deregistered and there are no new messages.

Observer's next() returns internal error

Error:

next() returns Internal error.

Cause:

The publisher is deregistered while its readers are active.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is unavailable, then the publisher is gone and there are no new messages.

History's read_from_history() doesn't return new messages

Error:

read_from_history() doesn't return any new messages; only returns older messages.

Cause:

The publisher is deregistered while its readers are active.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is unavailable, then the publisher is gone and there are no new messages.

InstantReader read_latest_message() returns internal error

Error:

read_latest_message() returns Internal error.

Cause:

The publisher is deregistered while its readers are active.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is unavailable, then the publisher is gone and there are no new messages.

Troubleshoot empty message queue

Errors can occur when attempting to read from an empty message queue.

Subscriber's read_next_messages() returns an empty list

Error:

read_next_messages() returns empty list successfully.

Cause:

The publisher is active, but hasn't sent messages.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is available, then the publisher is active and there are no new messages.

Observer's next() returns internal error

Error:

next() returns Internal error.

Cause:

The publisher is active, but hasn't sent messages.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is available, then the publisher is active and there are no new messages.

History's read_from_history() doesn't return new messages

Error:

read_from_history() returns empty list successfully.

Cause:

The publisher is active, but hasn't sent messages.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is available, then the publisher is active and there are no new messages.

InstantReader read_latest_message() returns internal error

Error:

read_latest_message() returns Internal error.

Cause:

The publisher is active, but hasn't sent messages.

Fix:

Use a subscriber or history with an availability stream. If the availability stream's last message is available, then the publisher is active and there are no new messages.

Troubleshoot buffer overflow or data loss

Errors can occur when the publisher sends messages at a faster rate than a reader can consume them.

Subscriber's first read after an overflow returns DataLoss error

Error:

read_next_message() returns DataLoss error.

Cause:

The publisher sends messages at a faster rate than a reader can consume them.

Fix:

Observer's first next() after an overflow returns DataLoss error

Error:

next() returns DataLoss error.

Cause:

The publisher sends messages at a faster rate than a reader can consume them.

Fix: Potential fixes are:

  • Publisher publishes at a slower rate. For example, you might have a variable with the timestamp of the latest message. If the current time is less than the latest publish time plus a delta, you don't publish the message. Using this mechanism, at most one message per delta is published.

  • Consumer uses an InstantRead object instead of an observer. An InstantRead object doesn't return overflow errors and always returns the last message. If the last message is the only one that matters to you, then you can use an InstantRead object instead of an observer.

  • Consumer implements sampling. If your solution has a publisher (P1) that publishes messages faster than the observer (01) can read them, you can create a new publisher (P2) and observer (02) to accommodate the difference in publishing and reading speed.

    For example, suppose P1 publishes a message every 10 ms, but O1 can read only one message every 100 ms and drops the remaining nine messages. To resolve the discrepancy, create a solution that follows these steps:

    1. P1 publishes messages to O2.
    2. O2 reads one message and drops nine.
    3. O2 sends the one read message to P2.
    4. P2 sends the one read message to O1.
    5. O1 reads one message every ten seconds.

    The following example code shows how to implement this sampling scenario:

    int discarded_message = 10;
    
    while (true) {
    message m = O2.read_message();
    if discarded_message == 10 {
      discarded_message = 0;
      P2.publish(m);
    } else {
     discarded_message ++;
    }
    }
    

History's reads are incomplete

Error:

Message is lost before history copy. No direct error notification on read.

Cause:

The publisher sends messages at a faster rate than a reader can consume them.

Fix:

InstantReader only reads last message

Error:

Message is lost before history copy. No direct error notification on read.

Cause:

The publisher sends messages at a faster rate than a reader can consume them.

Fix:

N/A

RPC client calls a method and method is unavailable

Error:

Method call fails with Unavailable error.

Cause:

SDV doesn't know the server name and returns Unavailable. This error is returned by the middleware if service discovery doesn't return a valid server name.

Fix:

Start a service bundle that defines a server for the given interface that the client wants to use.

Server-side implementation returns SdvStatus error

Error:

The server-side implementation returns an SdvResult containing an SdvStatus error, such as SdvStatusCode::NotFound. The error is propagated back to the calling client.

Cause:

SDV and the communication system between client and server works as expected, but the client made a request that triggers an error in the server.

Fix:

Make a valid request with the client or fix the server to successfully respond to those requests.