Connect to SCTP failed

I’m trying to send SCTP messages to a mediasoup router using usrsctp, but it won’t connect. Mediasoup is receiving my SCTP packets over UDP, but it gets to usrsctp_conninput() in SCTPAssociation.cpp then nothing seems to happen after that. Should I be getting a message back that I’m supposed to reply to?

I’m using data producers and data consumers, and I saw that an SCTP association is connected when I connect to mediasoup from a browser client. I saw that usrsctp_connect() gets called in the SCTPAssociation constructor, but I didn’t see onSendSctpData() get called after that, which I thought kicked off the process. I also saw that OnSctpAssociationConnected() did get called in Transport.cpp, but I can’t get that to call for my SCTP call to connect.

Ok, it was a usrsctp issue (I used wireshark to decode the UDP packets as SCTP, and realized I wasn’t replying to the INIT_ACK messages mediasoup was sending). So I got the handshake to complete and mediasoup received my message, but now the data consumer’s ‘message’ event is not firing. I can confirm the message is received by the data producer, and I know the router is calling SendMessage() on the data consumer, but I’m not sure why I’m not seeing it.

[id:32640f1e-6b75-4ed5-80f1-378d364d57e1] RTC::SctpAssociation::onRecvSctpData() | data chunk received [length:12, streamId:2, SSN:0, TSN:1673349121, PPID:51, context:0, flags:8]

// (THIS GETS CALLED)
plain_transport.on_sctp_state_change(|state| {
    println!("State changed: {:?}", state);
}).detach();

// setup data producer and consumer
let stream_id = 2;
match plain_transport.produce_data(DataProducerOptions::new_sctp(SctpStreamParameters::new_ordered(stream_id)))
.await
{
    Ok(data_producer) => {
        let data_producer_id = data_producer.id();

        // save data producer
        address.do_send(InternalMessage::SaveDataProducer(producer.clone(), data_producer.clone()));
        
        // create data consumer
        match plain_transport.consume_data(DataConsumerOptions::new_sctp(data_producer.id()))
        .await
        {
            Ok(data_consumer) => {
                let data_consumer_id = data_consumer.id();

                // save data consumer
                address.do_send(InternalMessage::SaveDataConsumer(data_consumer.clone()));

                // handle incoming data (THIS DOES NOT GET CALLED)
                data_consumer.on_message(|_msg| {
                    println!("MY SCTP MESSAGE WAS RECEIVED");
                }).detach();
            }
            Err(_) => {}
        }
    }
    Err(_) => {}
}

Had to use direct transport instead of plain transport for the data consumer. Message received!