240_publish_scenarios.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import inc_sip as sip
  2. import inc_sdp as sdp
  3. # Several PUBLISH failure scenarios that should be handled automatically
  4. pjsua = "--null-audio --id=sip:127.0.0.1:$PORT --registrar sip:127.0.0.1:$PORT " + \
  5. "--realm=python --user=username --password=password " + \
  6. "--auto-update-nat=0 --publish"
  7. #pjsua = "--null-audio --local-port 0 --rtp-port 0"
  8. # Handle REGISTER first
  9. req1 = sip.RecvfromTransaction("Initial REGISTER", 200,
  10. include=["REGISTER sip"],
  11. exclude=[],
  12. resp_hdr=["Expires: 1800"]
  13. )
  14. # First PUBLISH, reply with 412
  15. req2 = sip.RecvfromTransaction("Initial PUBLISH, will be replied with 412", 412,
  16. include=["PUBLISH sip"],
  17. exclude=["Expires:"]
  18. )
  19. # Second PUBLISH
  20. req3 = sip.RecvfromTransaction("Second PUBLISH, will be replied with 200", 200,
  21. include=["PUBLISH sip"],
  22. exclude=["Expires:"],
  23. resp_hdr=["Expires: 60", "SIP-ETag: dx200xyz"]
  24. )
  25. # PUBLISH refresh, respond with 408
  26. req4 = sip.RecvfromTransaction("PUBLISH refresh, will be replied with 408", 408,
  27. include=["PUBLISH sip", "SIP-If-Match: dx200xyz"],
  28. exclude=["Expires:"],
  29. resp_hdr=["Expires: 60", "SIP-ETag: dx200xyz"]
  30. )
  31. # After 5 minutes, pjsua should retry again
  32. req5 = sip.RecvfromTransaction("PUBLISH retry", 200,
  33. include=["PUBLISH sip"],
  34. exclude=["Expires:", "SIP-If-Match:"],
  35. resp_hdr=["Expires: 60", "SIP-ETag: abc"]
  36. )
  37. recvfrom_cfg = sip.RecvfromCfg("PUBLISH scenarios",
  38. pjsua, [req1, req2, req3])