412 Precondition Failed when Subscribing to an event

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

412 Precondition Failed when Subscribing to an event

Jean-Claude Dufourd
I have some code that is inspired directly from the manual, to subscribe to an event.
If I subscribe to the service when it is local, the subscription works.
If I subscribe to the service from another machine, the subscription fails with message:
412 Precondition failed
I traced the full message to be:
"No subscription ID, no NT or Callback, neither subscription or renewal"

I am lost and would appreciate a hint.
Best regards
JC

The service is:

...
@UpnpService(
        serviceId = @UpnpServiceId("COLTRAMAgent"),
        serviceType = @UpnpServiceType(value = "COLTRAMAgent", version = 1)
)
...
public class Agent implements Runnable {
...
    @UpnpStateVariable(defaultValue = "0", sendEvents = true)
    private String time = "";
...

    private final PropertyChangeSupport propertyChangeSupport;

    public Agent() {
        this.propertyChangeSupport = new PropertyChangeSupport(this);
        new Thread(this).start();
    }

    public PropertyChangeSupport getPropertyChangeSupport() {
        return propertyChangeSupport;
    }

    public void run() {
        while (true) {
            String s = new Date().getTime()+"";
            getPropertyChangeSupport().firePropertyChange("time", time, s);
            time = s;
            try {
                Thread.sleep(1000);
            } catch(InterruptedException e) {}
        }
    }
}

And the SubscriptionCallback:

public class SubscriptionCallback extends org.teleal.cling.controlpoint.SubscriptionCallback {
...
    public SubscriptionCallback(Service service, int timeOut, ...) {
        super(service, timeOut);
        ...
    }

...
    @Override
    public void established(GENASubscription sub) {
        log.info("subscription established");
    }

    @Override
    protected void failed(GENASubscription subscription,
                          UpnpResponse responseStatus,
                          Exception exception,
                          String defaultMsg) {
        log.info("subscription failed " + defaultMsg);
    }

    @Override
    public void ended(GENASubscription sub,
                      CancelReason reason,
                      UpnpResponse response) {
        log.info("subscription ended");
    }

    public void eventReceived(GENASubscription sub) {
...
    }

    public void eventsMissed(GENASubscription sub, int numberOfMissedEvents) {
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: 412 Precondition Failed when Subscribing to an event

Christian Bauer
Administrator
Trace log the server side.
Reply | Threaded
Open this post in threaded view
|

Re: 412 Precondition Failed when Subscribing to an event

Jean-Claude Dufourd
I am using cling 1.0.5
Here is a trace:

FINE ...erverImpl$RequestHttpHandler handle ............... Received HTTP exchange: SUBSCRIBE /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event
FINE ...l.cling.transport.RouterImpl received ............. Received synchronous stream: (HttpExchangeUpnpStream)
FINE ....impl.HttpExchangeUpnpStream run .................. Processing HTTP request: SUBSCRIBE /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event
FINE ....impl.HttpExchangeUpnpStream run .................. Created new request message: (StreamRequestMessage) SUBSCRIBE /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event
FINE ....impl.HttpExchangeUpnpStream run .................. Reading request body bytes: 0
FINE ....impl.HttpExchangeUpnpStream run .................. Request did not contain entity body
FINE ...ing.transport.spi.UpnpStream process .............. Processing stream request message: (StreamRequestMessage) SUBSCRIBE /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event
FINE ...protocol.ProtocolFactoryImpl createReceivingSync .. Creating protocol for incoming synchronous: (StreamRequestMessage) SUBSCRIBE /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event
FINE ...ing.transport.spi.UpnpStream process .............. Running protocol for synchronous message processing: (ReceivingSubscribe)
FINE ...ocol.sync.ReceivingSubscribe executeSync .......... Found local event subscription matching relative request URI: /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event
FINE ...ng.model.message.UpnpHeaders parseHeaders ......... Parsing all HTTP headers for known UPnP headers: 7
FINE ...el.message.header.UpnpHeader newInstance .......... Trying to parse 'TIMEOUT' with class: TimeoutHeader
FINE ...ng.model.message.UpnpHeaders addParsedValue ....... Adding parsed header: (TimeoutHeader) '600'
FINE ...el.message.header.UpnpHeader newInstance .......... Trying to parse 'HOST' with class: HostHeader
FINE ...ng.model.message.UpnpHeaders addParsedValue ....... Adding parsed header: (HostHeader) '137.194.232.180:63399'
FINE ...el.message.header.UpnpHeader newInstance .......... Trying to parse 'NT' with class: RootDeviceHeader
FINE ...el.message.header.UpnpHeader newInstance .......... Invalid header value for tested type: RootDeviceHeader - Invalid root device NT header value: upnp:event
FINE ...el.message.header.UpnpHeader newInstance .......... Trying to parse 'NT' with class: UDADeviceTypeHeader
FINE ...el.message.header.UpnpHeader newInstance .......... Invalid header value for tested type: UDADeviceTypeHeader - Invalid UDA device type header value, Can't parse UDA device type string (namespace/type/version): upnp:event
FINE ...el.message.header.UpnpHeader newInstance .......... Trying to parse 'NT' with class: UDAServiceTypeHeader
FINE ...ng.model.message.UpnpHeaders parseHeaders ......... Ignoring known but non-parsable header (value violates the UDA specification?) 'NT': upnp:event
FINE ...ng.model.message.UpnpHeaders parseHeaders ......... Ignoring non-UPNP HTTP header: Connection
FINE ...el.message.header.UpnpHeader newInstance .......... Trying to parse 'CALLBACK' with class: CallbackHeader
FINE ...ng.model.message.UpnpHeaders addParsedValue ....... Adding parsed header: (CallbackHeader) '[http://137.194.232.101:49530/dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event/cb.xml]'
FINE ...el.message.header.UpnpHeader newInstance .......... Trying to parse 'USER_AGENT' with class: UserAgentHeader
FINE ...ng.model.message.UpnpHeaders addParsedValue ....... Adding parsed header: (UserAgentHeader) 'Windows7/6.1 UPnP/1.0 Teleal-Cling/1.0'
FINE ...ng.model.message.UpnpHeaders parseHeaders ......... Ignoring non-UPNP HTTP header: Accept
FINE ...ocol.sync.ReceivingSubscribe executeSync .......... No subscription ID, no NT or Callback, neither subscription or renewal: (StreamRequestMessage) SUBSCRIBE /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event
FINE ...ing.transport.spi.UpnpStream process .............. Protocol returned response: (OutgoingSubscribeResponseMessage) 412 Precondition Failed
FINE ....impl.HttpExchangeUpnpStream run .................. Preparing HTTP response message: (OutgoingSubscribeResponseMessage) 412 Precondition Failed
FINE ....impl.HttpExchangeUpnpStream run .................. Sending HTTP response message: (OutgoingSubscribeResponseMessage) 412 Precondition Failed with content length: -1
FINE sun.net.httpserver.ServerImpl logReply ............... SUBSCRIBE /dev/7285eed2-5a37-90d0-0000-000029d217cf/svc/upnp-org/COLTRAMAgent/event HTTP/1.1 [412  Precondition Failed] ()
FINE ...et.httpserver.HttpConnection close ................ Closing connection: java.nio.channels.SocketChannel[connected local=/137.194.232.180:63399 remote=/137.194.232.101:49584]

The "invalid root device NT header value: upnp:event" feels weird.
Thanks for any hint.
Best regards
JC

Le 28/5/13 13:30 , Christian Bauer [via Mailinglists] a écrit :
Trace log the server side.



If you reply to this email, your message will be added to the discussion below:
http://mailinglists.945824.n3.nabble.com/412-Precondition-Failed-when-Subscribing-to-an-event-tp4025837p4025838.html
To start a new topic under Cling users and developers, email [hidden email]
To unsubscribe from Cling users and developers, click here.
NAML


-- 
JC Dufourd
Directeur d'Etudes/Professor
Groupe Multimedia/Multimedia Group
Traitement du Signal et Images/Signal and Image Processing
Telecom ParisTech, 37-39 rue Dareau, 75014 Paris, France 
Tel: +33145817733 - Mob: +33677843843 - Fax: +33145817144
Reply | Threaded
Open this post in threaded view
|

Re: 412 Precondition Failed when Subscribing to an event

Christian Bauer
Administrator
This is not Cling master code base.

Reply | Threaded
Open this post in threaded view
|

Re: 412 Precondition Failed when Subscribing to an event

Jean-Claude Dufourd
Wow! I am impressed.
Yes, the problem is mine, with a small relaxation of constraints on the ServiceType parsing, which I needed because I have to deal with non-compliant UPnP software.
Sorry to have taken your time for that.
Thanks
JC

Le 29/5/13 15:01 , Christian Bauer [via Mailinglists] a écrit :
This is not Cling master code base.




If you reply to this email, your message will be added to the discussion below:
http://mailinglists.945824.n3.nabble.com/412-Precondition-Failed-when-Subscribing-to-an-event-tp4025837p4025843.html
To start a new topic under Cling users and developers, email [hidden email]
To unsubscribe from Cling users and developers, click here.
NAML


--
Télécom
                  ParisTech Jean-Claude DUFOURD
Directeur d'études
Tél. : 01 45 81 77 33
37-39 rue Dareau
75014 Paris

Site webTwitterFacebookGoogle+Blog