Unreliably receiving NewParticipantEvent, ByeEvent

My JMF RTP client connects to the sending RTP server and successfully opens the ReceiveStreams and creates a player.
The problem is that sometimes it does not receive the ByeEvent when the server-side RTPManager's removeTargets() is called, thus the client never finds out the server is done transmitting. I have come across other desperate posts mentioning the exact same problem, but haven't found a solution listed for any of them.
The only other piece of information I have to add about this phenomenon is that the times when the ByeEvent was not received, the NewParticipantEvent had never been received either. This leads me to believe that either:
A.) the RTPManager (on the client side) only acknowledges ByeEvents from known participants, and since it didn't receive a NewParticipantEvent from the server-side (which would map the participant with a stream), it doesn't fire a ByeEvent, even when it receives the event on the RTP stream, or
B.) the RTPManager on the server side is simply not firing events to this client.
It is important to note that the behavior (not receiving these events on the client side), is sparatic: i.e. on some runs, it will receive the NewParticipantEvent and subsequently receive the ByeEvent when the server side closes the stream, and other runs (back-to-back, using the exact same build) it does not receive the NewParticipantEvent, thus doesn't receive the ByeEvent, and the client never knows the stream is finished.
I know this behavior has been seen before (from looking through past forum posts), but has anyone found a solution?

I think beta version3 of JMF fixed that problem. Visit http://java.sun.com/products/java-media/jmf/2.1.1/features.html
Look under the beta3 bug fixes and you'll see "bye event issue" a confirmed bug in the earlier versions. Maybe you might want to download a newer release of JMF.
I'm not very expert in Java, but I'm developing a video conferencing software myself. I might have a suggestion for you. Maybe you might want to use an extra port on each side to transmit data only. This way you can transmit a message on that extra port when the client is disconnected, connected and interpret that message on the server side to dispose your RTPManagers or fire events. And vice versa. You can basically listen for applet close or button action events to determine end of receivestream on client side, or even ping the server every once in a while to assure the connection is there using this extra port. It's more of an effort than simply listening to the "bye" event but, I hope that makes sense, it's just an idea. (I hope your application is not a port monster on server side)
If I can resolve my syncronization problems with starting, dealocationg and restarting my processors, I'll be having the same headache as you're having in a few days. So keep us posted if you find anything.. [email protected]

Similar Messages

  • Unreliable receiving hotmail from other hotmail users

    Is there a temporary problem with receiving mail from Hotmail at the moment? Im not talking about plug ins for my own hotmail account, I dont have anything set up, but hotmail from other people seems to be in transit for hours, and sometimes doesnt arrive! I have tried experimenting with gmail, and it arrives more or less as expected. But hotmail! I am still waiting for mail I know has been sent (half an hour, 8 hours..). My fiancee thinks I am ignoring her!
    Thanks

    If you are accessing your Hotmail account via webmail with a browser or with the Mail.app using the Hotmail plugin, Apple has nothing to do with this.
    Apple is responsible for the incoming and outgoing servers for .Mac email accounts only.
    Any problems sending or receiving email with a Hotmail account are caused by Microsoft servers or a temporary problem in transit between various servers.

  • VoIP with JMF

    hello,
    i'm trying to create a J2SE VoIP app with JMF. is it feasible?
    i've read that to overcome the NAT problem, we need to use Symmetry RTP. does it supported in JMF?
    i've done the SIP session managing with JSIP. now i need to send and receive RTP data.
    i've done this for the receiver
    url= "rtp://" + IP + ":" + port + "/audio/16";
    mrl= new MediaLocator(url);
    player = Manager.createPlayer(mrl);
    player.realize();
    // wait for realizing
    while (player.getState() != Player.Realized){
         try
    Thread.sleep(10);
    } catch (InterruptedException e)
    e.printStackTrace();
    player.start();
    with IP is the other party IP specified in the SDP, and the Port is the port specified in the SDP too.
    with wireshark, i've seen that RTCP is seen (Receiver Report, Source Description), and RTCP replies are received (Sender Report, Source Description), but RTP data is not received.
    i realize that JMF open the same local port as the port specified in the MediaLocator. while actually in my INVITE SDP, i tell the other party a different port. might this be the problem that i don't receive any RTP data?
    Thank you.

    Hey,
    No, the loss of packets isn't something you can control... you lose a packet, you lose a packet. The different encodings could have an affect on the impact of the packet loss, however, but the actual loss of the packet is out of everyone's hands. Even God loses packets as they travel on the wire...Well, I went again to Wiki to look for that page and you are right, I am wrong, it didn't say anything about packet loss, but it was referring to the call distortion and wrongly concluded something about the packets.
    Ummmm, maybe. The issue isn't as simple as knowing the public IP address of a client behind a NAT, it's also a matter of traversing the NAT itself. But if the SIP UAS handles all of that, then yes, you should be fine.after putting it to the test, I'm really confused...
    I'll try to lay it out so it would make sense and if that wont work I'll post my code here. there is just a lot of it in a few classes.
    This is tested with one way streaming!
    *1.* I've been trying to transmit audio and video within my home LAN, I've managed to send from one computer to the other, from beginning to end.
    This is what I receive on the callee computer in my home LAN:
    Participant added to list: ACER-LAPTOP/10.0.0.2
      - A new participant had just joined: TacB0sS@Acer-LapTop
    New Stream Event received: StreamMappedEvent
      Stream: com.sun.media.rtp.RecvSSRCInfo@13e6346
      Participant: com.sun.media.rtp.RTPRemoteSourceInfo@1cb374f
      Source: RTPManager
         SSRCCache  com.sun.media.rtp.SSRCCache@cc9d70
         Dataport  33444
         Controlport  33445
         Address  10.0.0.1
         RTPForwarder  com.sun.media.rtp.util.PacketForwarder@17456bc
         RTPDemux  com.sun.media.rtp.RTPDemultiplexer@ea85b4
    New Stream Event received: NewReceiveStreamEvent
      Stream: com.sun.media.rtp.RecvSSRCInfo@13e6346
      Participant: com.sun.media.rtp.RTPRemoteSourceInfo@1cb374f
      Source: RTPManager
         SSRCCache  com.sun.media.rtp.SSRCCache@cc9d70
         Dataport  33444
         Controlport  33445
         Address  10.0.0.1
         RTPForwarder  com.sun.media.rtp.util.PacketForwarder@17456bc
         RTPDemux  com.sun.media.rtp.RTPDemultiplexer@ea85b4
    new stream arrived fromcom.sun.media.rtp.RTPRemoteSourceInfo@1cb374f
      - Recevied new RTP stream: JPEG/RTP*2.* But when I try to transmit to my friends computer, which is far far away... I do receive NewParticipantEvent, and I do get StreamMappedEvent, but no NewReceivedStreamEvent. sometimes I received an InactiveReceivedStreamEvent but to the caller computer, not to the callee. I thought perhaps the log would help:
    This is what I get when I try to call my friends remote computer, on his computer:
    Participant added to list: xx.xx.xx.xx.bb.netvision.net.il/xx.xx.xx.xx
      - A new participant had just joined: TacB0sS@dell-laptop
    New Stream Event received: StreamMappedEvent
      Stream: com.sun.media.rtp.RecvSSRCInfo@198a455
      Participant: com.sun.media.rtp.RTPRemoteSourceInfo@aa37a6
      Source: RTPManager
    SSRCCache  com.sun.media.rtp.SSRCCache@12b7eea
    Dataport  33444
    Controlport  33445
    Address  192.168.2.101
    RTPForwarder  com.sun.media.rtp.util.PacketForwarder@99353f
    RTPDemux  com.sun.media.rtp.RTPDemultiplexer@76e369
    And this is what I get on my computer when I call my friends:
    New Stream Event received: InactiveReceiveStreamEvent
      Stream: null
      Participant: com.sun.media.rtp.RTPRemoteSourceInfo@7b7b11
      Source: RTPManager
         SSRCCache  com.sun.media.rtp.SSRCCache@cc9d70
         Dataport  33444
         Controlport  33445
         Address  10.0.0.1
         RTPForwarder  com.sun.media.rtp.util.PacketForwarder@17456bc
         RTPDemux  com.sun.media.rtp.RTPDemultiplexer@ea85b4This is really bigger then me, we've tried to play a bit with configuration, but I just don't see the point, some events are received some are not...
    What am I missing?
    Thanks,
    Adam.
    Edited by: Adam-Z. on Jun 14, 2010 7:34 PM

  • Unreliable behavior of MulticastSocket's receive method

    I have a program that uses one MulticastSocket to receive packets from a multicast address on a given port (running on a dedicated thread), and another MulticastSocket to send both multicast- and unicast-adressed packets from the same port (running on a separate thread). The program runs on a Windows system that communicates with a separate program (written in C++) running on a Linux system (more specifically, a Gumstix processor running Ubuntu). Both applications are written to send some messages by multicast, and others by direct unicast, with all sending and receiving being performed using the same port number.
    The problem I'm having is this... The MulticastSocket SOMETIMES receives packets sent by the remote system by BOTH multicast addressing AND unicast addressing, but other times, ONLY receives the packets sent by multicast addressing. By "sometimes" and "other times," I mean "distinct executions of the program." That is, if I run it one time, the MulticastSocket ALWAYS behaves one way, and if I run the same program again, it ALWAYS behaves the other way.
    I know that this smacks of thread-interaction issues, but I have done due diligence to rule this out as best I can.
    All of the documentation about MulticastSocket says that it is perfectly reasonable to create multiple MulticastSockets on the same socket address (i.e., the same port), by virtue of the fact that the class sets SO_REUSEADDR to true by default. But if the code never instantiates the sending MulticastSocket, the receiver seems to receive unicast-addressed packets quite reliably.
    How can I ensure that the receiving MulticastSocket behaves in a predictable manner? Are there known issues with this?

    I don't understand why you're using two MulticastSockets for this. You can send and receive from the same MulticastSocket simultaneously.

  • Why receiver is stopped

    i am creating rtp mixer .
    for that i have made a program which receive rtp stream and then transmit it .
    The problem with this code is that it first create receiver(it is a player) from the received rtp stream but receiver is stopped when treansmitter
    (it is a processor) is created.
    Earlier i was creaing the playe and processor from the same dataSourc so i thought it was creating problem . so i created transmitter (processor)
    from the cloned dataSource . but the problem reamain as it was
    what is the reason for this.
    please help me because i am already late in this project .
    very very thank u.
    my code is :
    import java.awt.*;
    import java.io.IOException;
    import java.net.*;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.util.Vector;
    import javax.media.*;
    import javax.media.rtp.*;
    import javax.media.rtp.event.*;
    import javax.media.rtp.rtcp.SourceDescription;
    import javax.media.control.TrackControl;
    import javax.media.protocol.DataSource;
    import javax.media.protocol.*;
    public class AVReceive implements ReceiveStreamListener, SessionListener,
              ControllerListener {
         String session[];
         static RTPManager mgrs;
         Vector playerWindows = null;
         static ArrayList list = new ArrayList();
         private Processor processor = null;
         String result = null;
         DataSource mds;
         private Integer stateLock = new Integer(0);
         DataSource dataOutput;
         public static int incr = 0;
         public static int inc;
         DataSource cloneableDataSource = null;
    DataSource clonedDataSource = null;
         private boolean failed = false;
         boolean dataReceived = false;
         DataSource ds = null;
         Object dataSync = new Object();
         protected boolean initialize() {
              try {
                   InetAddress ipAddr;
                   SessionAddress localAddr = new SessionAddress();
                   SessionAddress destAddr;
                   playerWindows = new Vector();
                   mgrs = (RTPManager) RTPManager.newInstance();
                   mgrs.addSessionListener(this);
                   mgrs.addReceiveStreamListener(this);
                   localAddr = new SessionAddress(InetAddress.getLocalHost(), 5004);
                   mgrs.initialize(localAddr);
                   destAddr = new SessionAddress(InetAddress.getLocalHost(), 20000);
                   mgrs.addTarget(destAddr);
              } catch (Exception e) {
                   System.err.println("Cannot create the RTP Session: "
                             + e.getMessage());
                   return false;
              return true;
         public boolean isDone() {
              return playerWindows.size() == 0;
         protected void close() {
              for (int i = 0; i < playerWindows.size(); i++) {
                   try {
                        ((PlayerWindow) playerWindows.elementAt(i)).close();
                   } catch (Exception e) {
              playerWindows.removeAllElements();
              if (mgrs != null) {
                   mgrs.removeTargets("Closing session from AVReceive");
                   mgrs.dispose();
                   mgrs = null;
         PlayerWindow find(Player p) {
              for (int i = 0; i < playerWindows.size(); i++) {
                   PlayerWindow pw = (PlayerWindow) playerWindows.elementAt(i);
                   if (pw.player == p)
                        return pw;
              return null;
         PlayerWindow find(ReceiveStream strm) {
              for (int i = 0; i < playerWindows.size(); i++) {
                   PlayerWindow pw = (PlayerWindow) playerWindows.elementAt(i);
                   if (pw.stream == strm)
                        return pw;
              return null;
         public synchronized void update(SessionEvent evt) {
              if (evt instanceof NewParticipantEvent) {
                   Participant p = ((NewParticipantEvent) evt).getParticipant();
                   System.out.println(" A new participant has just joined: "
                             + p.getCNAME());
         public synchronized void update(ReceiveStreamEvent evt) {
              Participant participant = evt.getParticipant();
              ReceiveStream stream = evt.getReceiveStream();
              if (evt instanceof NewReceiveStreamEvent) {
                   try {
                        stream = ((NewReceiveStreamEvent) evt).getReceiveStream();
                        if (stream != null)
                             System.out.println(" - Recevied new RTP stream");
                        ds = stream.getDataSource();
              Player p = javax.media.Manager.createPlayer(ds);
                        if (p == null) {
                             System.out.println("can not create player");
                             return;
                        System.out.println("player is created ");
                        p.addControllerListener(this);
                        p.realize();
                        synchronized (dataSync) {
                             dataSync.notifyAll();
                        inc++;
                        PlayerWindow pw = new PlayerWindow(p, stream, inc);
                        playerWindows.addElement(pw);
                   } catch (Exception e) {
                        System.err.println("NewReceiveStreamEvent exception "
                                  + e.getMessage());
                        return;
              } else if (evt instanceof StreamMappedEvent) {
                   if (stream != null && stream.getDataSource() != null) {
                        System.out.println(" has now been identified as sent by: "
                                  + participant.getCNAME());
                        incr++;
                        try {
                             Vector sourceDescriptions = stream.getParticipant()
                                       .getSourceDescription();
                                                 for (int i = 0; i < sourceDescriptions.size(); i++) {
                                  SourceDescription description = (SourceDescription) sourceDescriptions
                                            .get(i);
                                  if (description.getType() == SourceDescription.SOURCE_DESC_CNAME) {
                                       String ip[] = description.getDescription().split(
                        } catch (Exception e) {
                             System.out.println(" exception is " + e);
                        System.out.println(" creating transmitter ");
                        createProcessor();
                        processor.start();
                        PlayerWindow pw = new PlayerWindow(processor);
                        playerWindows.addElement(pw);
                        pw.initialize1();
                        pw.setVisible(true);
                        createTransmitter();
              } else if (evt instanceof ByeEvent) {
                   System.err.println(" - Got \"bye\" from: "
                             + participant.getCNAME());
                   PlayerWindow pw = find(stream);
                   if (pw != null) {
                        pw.close();
                        playerWindows.removeElement(pw);
         private String createProcessor() {
    cloneableDataSource
    = Manager.createCloneableDataSource(ds);
              try {
                   processor = javax.media.Manager.createProcessor(cloneableDataSource);
              } catch (NoProcessorException npe) {
                   return "Couldn't create processor";
              } catch (IOException ioe) {
                   return "IOException creating processor";
              boolean result = waitForState(processor, Processor.Configured);
              if (result == false)
                   return "Couldn't configure processor";
              TrackControl[] tracks = processor.getTrackControls();
              if (tracks == null || tracks.length < 1)
                   return "Couldn't find tracks in processor";
              ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
              processor.setContentDescriptor(cd);
              Format supported[];
              Format chosen;
              boolean atLeastOneTrack = false;
              for (int i = 0; i < tracks.length; i++) {
                   if (tracks.isEnabled()) {
                        supported = tracks[i].getSupportedFormats();
                        if (supported.length > 0) {
                             chosen = supported[0];
                             tracks[i].setFormat(chosen);
                             System.err
                                       .println("Track " + i + " is set to transmit as:");
                             System.err.println(" " + chosen);
                             atLeastOneTrack = true;
                        } else
                             tracks[i].setEnabled(false);
                   } else
                        tracks[i].setEnabled(false);
              if (!atLeastOneTrack)
                   return "Couldn't set any of the tracks to a valid RTP format";
              result = waitForState(processor, Controller.Realized);
              if (result == false)
                   return "Couldn't realize processor";
              dataOutput = processor.getDataOutput();
              System.out.println("dataoutput is " + dataOutput);
              return null;
         private void createTransmitter() {
              System.out.println("inside transmitter");
              PushBufferDataSource pbds = (PushBufferDataSource) dataOutput;
              PushBufferStream pbss[] = pbds.getStreams();
              System.out.println(" length of stream "+pbss.length);
              SessionAddress localAddr, destAddr1, destAddr2;
              InetAddress ipAddr1, ipAddr2;
              SendStream sendStream;
              int port = 0;
              SourceDescription srcDesList[];
              try {
                   sendStream = mgrs.createSendStream(dataOutput, 0);
                   System.out.println(" send stream is " + sendStream);
                   sendStream.start();
              } catch (Exception e) {
                   e.getMessage();
         Integer getStateLock() {
              return stateLock;
         void setFailed() {
              failed = true;
         private synchronized boolean waitForState(Processor p, int state) {
              p.addControllerListener(new StateListener());
              failed = false;
              System.out.println("inside configuring");
              if (state == Processor.Configured) {
                   System.out.println(" ok 4 ");
                   p.configure();
              } else if (state == Processor.Realized) {
                   p.realize();
              while (p.getState() < state && !failed) {
                   synchronized (getStateLock()) {
                        try {
                             getStateLock().wait();
                        } catch (InterruptedException ie) {
                             return false;
              System.out.println(" ok 3 ");
              if (failed)
                   return false;
              else
                   return true;
         public synchronized void controllerUpdate(ControllerEvent ce) {
              Player p = (Player) ce.getSourceController();
              if (p == null)
                   return;
              if (ce instanceof RealizeCompleteEvent) {
                   synchronized (dataSync) {
                        dataSync.notifyAll();
                   System.out.println(" player has been realized");
                   PlayerWindow pw = find(p);
                   if (pw == null) {
                        System.err.println("Internal error!");
                        System.exit(-1);
                   pw.initialize();
                   pw.setVisible(true);
                   p.start();
              if (ce instanceof ControllerErrorEvent) {
                   p.removeControllerListener(this);
                   PlayerWindow pw = find(p);
                   if (pw != null) {
                        pw.close();
                        playerWindows.removeElement(pw);
         class StateListener implements ControllerListener {
              public void controllerUpdate(ControllerEvent ce) {
                   if (ce instanceof ControllerClosedEvent) {
                        setFailed();
                   if (ce instanceof ControllerEvent) {
                        synchronized (getStateLock()) {
                        getStateLock().notifyAll();
         class PlayerWindow extends Frame implements ActionListener {
              public int inc;
              PlayerWindow() {
              Player player;
              ReceiveStream stream;
              PlayerWindow(Player p, ReceiveStream strm, int inc) {
                   player = p;
                   stream = strm;
                   this.inc = inc;
              PlayerWindow(Player p) {
                   player = p;
              public void initialize() {
                   add(new PlayerPanel(player, inc));
              public void initialize1() {
                   add(new PlayerPanel1(player, inc));
              public void close() {
                   player.close();
                   setVisible(false);
                   dispose();
              public void addNotify() {
                   super.addNotify();
                   pack();
              public void actionPerformed(ActionEvent e) {
                   if (e.getActionCommand() == "stop1") {
                        PlayerWindow pw = find(stream);
                        if (pw != null) {
                             pw.close();
                             playerWindows.removeElement(pw);
         class PlayerPanel extends Panel {
              Component vc, cc;
              PlayerPanel(Player p, int inc) {
                   setLayout(new BorderLayout());
                   if ((cc = p.getControlPanelComponent()) != null)
                        add("South", cc);
                   System.out.println("increment is " + inc);
                   Integer in = new Integer(inc);
                   Button counter = new Button("receiver" + in.toString());
                   Button stop1 = new Button("stop1");
                   add("Center", stop1);
                   add("North", counter);
                   PlayerWindow pw = find(p);
                   stop1.addActionListener(pw);
              public Dimension getPreferredSize() {
                   int w = 0, h = 200;
                   if (cc != null) {
                        Dimension size = cc.getPreferredSize();
                        if (w == 0)
                             w = size.width * 2;
                        h += size.height;
                   return new Dimension(w, h);
         class PlayerPanel1 extends Panel {
              Component vc, cc;
              PlayerPanel1(Player p, int inc) {
                   setLayout(new BorderLayout());
                   if ((cc = p.getControlPanelComponent()) != null)
                        add("South", cc);
                   System.out.println("increment is " + inc);
                   Integer in = new Integer(inc);
                   Button counter = new Button("transmitter" + in.toString());
                   Button stop1 = new Button("start");
                   add("Center", stop1);
                   add("North", counter);
                   PlayerWindow pw = find(p);
                   stop1.addActionListener(pw);
              public Dimension getPreferredSize() {
                   int w = 0, h = 200;
                   if (cc != null) {
                        Dimension size = cc.getPreferredSize();
                        if (w == 0)
                             w = size.width * 2;
                        h += size.height;
                   return new Dimension(w, h);
         public static void main(String argv[]) {
              AVReceive avReceive1 = new AVReceive();
              if (!avReceive1.initialize()) {
                   System.err.println("Failed to initialize the sessions.");
                   System.exit(-1);
              try {
                   while (true)
                        Thread.sleep(1000);
              } catch (Exception e) {

    hi jcparques
    thank for ur response .
    but i m not able to see ur code .
    so please allow me to see ur code.
    i have sent request to join ur project but i got denied reply.
    so accept my request.
    thank u.

  • AVReceiver2 only received two ReceiveStreamEvents

    Hi, I am new to JMF. I tailed the AVReceiver2 but it can only receive two ReceiveStreamEvents, one is NewReceiveStreamEvent and the other, StreamMappedEvent as I ran and traced the code. Below is the code.
    JMF gurus, thanks in advance for your help.
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.util.Vector;
    import javax.media.*;
    import javax.media.rtp.*;
    import javax.media.rtp.event.*;
    import javax.media.protocol.*;
    import javax.media.format.AudioFormat;
    import javax.media.format.VideoFormat;
    import javax.media.Format;
    import javax.media.control.BufferControl;
    import javax.media.control.MpegAudioControl;
    import javax.media.control.FrameRateControl;
    import org.apache.log4j.Logger;
    public class Receiver implements ReceiveStreamListener, SessionListener, ControllerListener {
         private static final Logger logger =
                 Logger.getLogger(Receiver.class);
        private RTPManager recvMgrs[] = null;
        private static boolean bye=false;
        boolean dataReceived = false;   
        Socket socketRTPReceiver=null;
        Socket socketRTCPReceiver=null;
        private String localAddr = null;
        private int localPort;
        private String remoteAddr = null;
        private int remotePort;
        private int ttl;
        private long timeStamp = 0;
        public Receiver (int localPort, String remoteAddr, int remotePort, int ttl, int AVOpt) {         
             this.localPort = localPort;
             this.remoteAddr = remoteAddr;
             this.remotePort = remotePort;
             this.ttl = ttl;         
             //generate a single RTP manager only for audio stream,
             if ((AVOpt == 0) || (AVOpt == 1)) //either audio only or video only
                  recvMgrs = new RTPManager[1];
             else if (AVOpt == 2) //receive both audio and video
                  recvMgrs = new RTPManager[2];
        private boolean initilaize () {
             InetAddress ipAddr;
             SessionAddress localAddr = new SessionAddress();
             SessionAddress destAddr;
             if (recvMgrs == null)
                  return false;
             try {
                  for (int i= 0; i<recvMgrs.length; i++) {              
                       recvMgrs[i] = (RTPManager) RTPManager.newInstance();
                       recvMgrs.addSessionListener(this);
                   recvMgrs[i].addReceiveStreamListener(this);
                   ipAddr = InetAddress.getByName(getRemoteAddr());
                   localAddr= new SessionAddress( InetAddress.getLocalHost(),
                        getLocalPort());
                   destAddr = new SessionAddress( ipAddr, getRemotePort());
                   logger.debug("======== ====== detsAddr = " + getRemoteAddr() + "remotePort = " + getRemotePort());               
                   logger.debug("======== ====== localAddr = " + InetAddress.getLocalHost() + "localPort = " + getLocalPort());
                   recvMgrs[i].initialize( localAddr);
                   // You can try out some other buffer size to see
                   // if you can get better smoothness.
                   BufferControl bc = (BufferControl)recvMgrs[i].getControl("javax.media.control.BufferControl");
                   if (bc != null)
                        bc.setBufferLength(350);
                   recvMgrs[i].addTarget(destAddr);
         } catch (Exception e){
              logger.error("Cannot create the RTP Session: " + e.getMessage());
              return false;
    return true;
    public void start () {
         if (! initilaize())
              logger.fatal("cannot start the Receiver.initialize()");
    public void stop () {
         // close the RTP session.
         logger.debug("========= Stop the receiver now ......");
         for (int i = 0; i < recvMgrs.length; i++) {
              if (recvMgrs[i] != null) {
                   recvMgrs[i].removeReceiveStreamListener(this);
                   recvMgrs[i].removeSessionListener(this);
                   recvMgrs[i].removeTargets( "Closing session from Receiver");
                   recvMgrs[i].dispose();
                   recvMgrs[i] = null;
    public synchronized void update(SessionEvent evt)
    if (evt instanceof NewParticipantEvent)
    Participant p = ((NewParticipantEvent) evt).getParticipant();
    logger.info("A new participant had just joined: " + p.getCNAME());
    public synchronized void update(ReceiveStreamEvent evt)
    Participant participant = evt.getParticipant(); // could be null.
    ReceiveStream stream = evt.getReceiveStream(); // could be null.
    if (evt instanceof RemotePayloadChangeEvent)
    logger.warn("Received an RTP PayloadChangeEvent," +
    " not supported cannot handle payload change.");
         //TBA: close this session
         //close();
    else if (evt instanceof NewReceiveStreamEvent)
         logger.debug("receiving a new ReceiveStreamEvent .....!");
    try
    stream = ((NewReceiveStreamEvent) evt).getReceiveStream();
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl =
    (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
    if (ctl != null)
    logger.info("Recevied new RTP stream: " + ctl.getFormat());
    else {
    logger.info("Recevied new RTP stream");
    if (participant == null)
    logger.info("The sender of this stream" +
    "had yet to be identified.");
    else
    logger.info("The stream comes from: " +
    participant.getCNAME());
    catch (Exception e)
    logger.warn("NewReceiveStreamEvent exception ", e);
    return;
    else if (evt instanceof StreamMappedEvent)
         logger.debug ("receiving StreammappedEvent ....");
    if (stream != null && stream.getDataSource() != null)
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl =
    (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
    logger.info("The previously unidentified stream ");
    if (ctl != null)
    logger.info(": " + ctl.getFormat());
    logger.info(" had now been identified as sent by: "
    + participant.getCNAME());
    else if (evt instanceof ByeEvent)
    logger.info("Got \"bye\" from: " + participant.getCNAME());
    public synchronized void controllerUpdate(ControllerEvent ce)
         logger.debug ("receiving controlUpdate ..........");
         return;      

    I changed the code with threading model and RTPConnectionAdapter as below. almost same as avReceiver2 or avReceiver3. Once the code starts, it is in the a while-loop, sleeping, then printing a log. So, I can know the thread is alive and wait for any new streamEvent from update(), I hope. Unfortuantely, from the log of RTPConnectionAdaptor, the UDP socket kept receiving datagram packets from the network(I confirmed from SockInputStream.read() and SockInputStream.run()), but the Receiver thread still only received two ReceiverStreamEvents. It is very frustrated. Could anyone explain what is going wrong in the code? Thanks in advance,
    public class Receiver extends Thread implements ReceiveStreamListener, SessionListener, ControllerListener {
         private static final Logger logger =
                 Logger.getLogger(Receiver.class);
        private RTPManager recvMgrs[] = null;
        private static boolean bye=false;
        private String localAddr = null;
        private int localPort;
        private String remoteAddr = null;
        private int remotePort;
        private int ttl;
        private long timeStamp = 0;
        public Receiver (int localPort, String remoteAddr, int remotePort, int ttl, int AVOpt) {         
             this.localPort = localPort;
             this.remoteAddr = remoteAddr;
             this.remotePort = remotePort;
             this.ttl = ttl;         
             //generate a single RTP manager only for audio stream,
             if ((AVOpt == 0) || (AVOpt == 1)) //either audio only or video only
                  recvMgrs = new RTPManager[1];
             else if (AVOpt == 2) //receive both audio and video
                  recvMgrs = new RTPManager[2];
            initilaize ();
         running = true;
        private boolean initilaize () {
             InetAddress ipAddr;
             SessionAddress localAddr = new SessionAddress();
             SessionAddress destAddr;
             if (recvMgrs == null)
                  return false;
             try {
                  for (int i= 0; i<recvMgrs.length; i++) {              
                       recvMgrs[i] = (RTPManager) RTPManager.newInstance();
                       recvMgrs.addSessionListener(this);
                   recvMgrs[i].addReceiveStreamListener(this);
                   ipAddr = InetAddress.getByName(getRemoteAddr());
                   localAddr= new SessionAddress( InetAddress.getLocalHost(),
                        getLocalPort());
                   destAddr = new SessionAddress( ipAddr, getRemotePort());
                   logger.debug("======== ====== detsAddr = " + getRemoteAddr() + "remotePort = " + getRemotePort());               
                   logger.debug("======== ====== localAddr = " + InetAddress.getLocalHost() + "localPort = " + getLocalPort());
                   recvMgrs[i].initialize(new RTPSocketAdapter(InetAddress.getLocalHost(), getLocalPort(), ttl));
                   // You can try out some other buffer size to see
                   // if you can get better smoothness.
                   BufferControl bc = (BufferControl)recvMgrs[i].getControl("javax.media.control.BufferControl");
                   if (bc != null)
                        bc.setBufferLength(350);
                   recvMgrs[i].addTarget(destAddr);
         } catch (Exception e){
              logger.error("Cannot create the RTP Session: " + e.getMessage());
              return false;
    return true;
    public void halt () {
         running = false;
    public void run () {
              while (running) {
                   logger.debug ("get into running-while loop ....1111");               
                   sleep(3000);
              close();
    public void close () {
         // close the RTP session.
         logger.debug("========= Stop the receiver now ......");
         for (int i = 0; i < recvMgrs.length; i++) {
              if (recvMgrs[i] != null) {
                   recvMgrs[i].removeReceiveStreamListener(this);
                   recvMgrs[i].removeSessionListener(this);
                   recvMgrs[i].removeTargets( "Closing session from Receiver");
                   recvMgrs[i].dispose();
                   recvMgrs[i] = null;
    public synchronized void update(SessionEvent evt)
    if (evt instanceof NewParticipantEvent)
    Participant p = ((NewParticipantEvent) evt).getParticipant();
    logger.info("A new participant had just joined: " + p.getCNAME());
    public synchronized void update(ReceiveStreamEvent evt)
    Participant participant = evt.getParticipant(); // could be null.
    ReceiveStream stream = evt.getReceiveStream(); // could be null.
    if (evt instanceof RemotePayloadChangeEvent)
    logger.warn("Received an RTP PayloadChangeEvent," +
    " not supported cannot handle payload change.");
         //TBA: close this session
         //close();
    else if (evt instanceof NewReceiveStreamEvent)
         logger.debug("receiving a new ReceiveStreamEvent .....!");
    try
    stream = ((NewReceiveStreamEvent) evt).getReceiveStream();
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl =
    (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
    if (ctl != null)
    logger.info("Recevied new RTP stream: " + ctl.getFormat());
    else {
    logger.info("Recevied new RTP stream");
    if (participant == null)
    logger.info("The sender of this stream" +
    "had yet to be identified.");
    else
    logger.info("The stream comes from: " +
    participant.getCNAME());
    catch (Exception e)
    logger.warn("NewReceiveStreamEvent exception ", e);
    return;
    else if (evt instanceof StreamMappedEvent)
         logger.debug ("receiving StreammappedEvent ....");
    if (stream != null && stream.getDataSource() != null)
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl =
    (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
    logger.info("The previously unidentified stream ");
    if (ctl != null)
    logger.info(": " + ctl.getFormat());
    logger.info(" had now been identified as sent by: "
    + participant.getCNAME());
    else if (evt instanceof ByeEvent)
    logger.info("Got \"bye\" from: " + participant.getCNAME());
    public synchronized void controllerUpdate(ControllerEvent ce)
         logger.debug ("receiving controlUpdate ..........");
         return;      

  • Big problem with put the same received dataSource on two different panels

    Hello All!
    I have a big problem, but first what have I done:
    I am writting application that is based on AVReceiver2 and AVTransmit2 from Sun help.
    I have modified AVReceiver2 to only receive one stream - video stream.
    I show received video on scrollPane, but I want to show the same video on second scrollPane in the same time. I have read about cloning dataSource, but I don't know how to modify that code to make it work.
    This is my receiver class (logger is my own class that have listbox, so don't watch on it. This is not important):
    public class Po&#322;&#261;czenie implements ReceiveStreamListener, SessionListener,
         ControllerListener
        String session = null;
        RTPManager manager = null;
        public Player player1 = null;
        boolean dataReceived = false;
        Object dataSync = new Object();
        private Logger logger;
        private JPanel&#377;ród&#322;oPo&#322;&#261;czone panelOgólny;
        private JPanel&#377;ród&#322;oSzczegó&#322;y panelSzczegó&#322;y;
        private Date dataRozpocz&#281;cia;
        public Po&#322;&#261;czenie(String session, JPanel&#377;ród&#322;oSzczegó&#322;y panelSzczegó&#322;y, JPanel&#377;ród&#322;oPo&#322;&#261;czone panelOgólny, Logger logger) {
            this.session = session;
            this.logger = logger;
            this.panelOgólny = panelOgólny;
            this.panelSzczegó&#322;y = panelSzczegó&#322;y;
        public void Start()
            if (!initialize())
                System.err.println("Failed to initialize the sessions.");
                System.exit(-1);
                System.err.println("Odbiór rozpocz&#281;ty");
        public boolean initialize() {
            try {
             InetAddress ipAddr;
             SessionAddress localAddr = new SessionAddress();
             SessionAddress destAddr;
             SessionLabel sessionLabel;
             // Open the RTP sessions.
               // Parse the session addresses.
              try {
                  sessionLabel = new SessionLabel(session);
              } catch (IllegalArgumentException e) {
                  System.err.println("Failed to parse the session address given: " + session);
                  return false;
              System.err.println("  - Otwarcie sesji RTP: addr: " + sessionLabel.addr + " port: " + sessionLabel.port + " ttl: " + sessionLabel.ttl);
              manager = (RTPManager) RTPManager.newInstance();
              manager.addSessionListener(this);
              manager.addReceiveStreamListener(this);
              ipAddr = InetAddress.getByName(sessionLabel.addr);
              if( ipAddr.isMulticastAddress()) {
                  // local and remote address pairs are identical:
                  localAddr= new SessionAddress( ipAddr,
                                     sessionLabel.port,
                                     sessionLabel.ttl);
                  destAddr = new SessionAddress( ipAddr,
                                     sessionLabel.port,
                                     sessionLabel.ttl);
              } else {
                  localAddr= new SessionAddress( InetAddress.getLocalHost(),
                                          sessionLabel.port);
                        destAddr = new SessionAddress( ipAddr, sessionLabel.port);
              manager.initialize( localAddr);
              // You can try out some other buffer size to see
              // if you can get better smoothness.
              BufferControl bc = (BufferControl)manager.getControl("javax.media.control.BufferControl");
              if (bc != null)
                  bc.setBufferLength(350);
                  manager.addTarget(destAddr);
            } catch (Exception e){
                System.err.println("Cannot create the RTP Session: " + e.getMessage());
                return false;
         // Wait for data to arrive before moving on.
         long then = System.currentTimeMillis();
         long waitingPeriod = 30000;  // wait for a maximum of 30 secs.
         try{
             synchronized (dataSync) {
              while (!dataReceived &&
                   System.currentTimeMillis() - then < waitingPeriod) {
                  if (!dataReceived)
                   System.err.println("  - Oczekiwanie na transmisj&#281; danych...");
                  dataSync.wait(1000);
         } catch (Exception e) {}
         if (!dataReceived) {
             System.err.println("No RTP data was received.");
             close();
             return false;
            return true;
         * Close the players and the session managers.
        protected void close() {
             try {
                player1.close();
             } catch (Exception e) {}
         // close the RTP session.
             if (manager != null) {
                    manager.removeTargets( "Closing session from AVReceive2");
                    manager.dispose();
                    manager = null;
         * SessionListener.
        public synchronized void update(SessionEvent evt) {
         if (evt instanceof NewParticipantEvent) {
             Participant p = ((NewParticipantEvent)evt).getParticipant();
             System.err.println("  - Do&#322;&#261;czy&#322; nowy u&#380;ytkownik: " + p.getCNAME());
         * ReceiveStreamListener
        public synchronized void update( ReceiveStreamEvent evt) {
         RTPManager mgr = (RTPManager)evt.getSource();
         Participant participant = evt.getParticipant();     // could be null.
         ReceiveStream stream = evt.getReceiveStream();  // could be null.
         if (evt instanceof RemotePayloadChangeEvent) {
             System.err.println("  - Received an RTP PayloadChangeEvent.");
             System.err.println("Sorry, cannot handle payload change.");
             System.exit(0);
         else if (evt instanceof NewReceiveStreamEvent) {
             try {
              stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
              DataSource ds = stream.getDataSource();
    //=========important thing:
                            DataSource cloneableDS = Manager.createCloneableDataSource( ds );
                            DataSource clonedDS = ((SourceCloneable)cloneableDS).createClone();
    //========
              // Find out the formats.
              RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
              if (ctl != null){
                  System.err.println("  - Recevied new RTP stream: " + ctl.getFormat());
              } else {
                  System.err.println("  - Recevied new RTP stream");
              if (participant == null)
                  System.err.println("      The sender of this stream had yet to be identified.");
              else {
                  System.err.println("      The stream comes from: " + participant.getCNAME());
              // create a player by passing datasource to the Media Manager
    //=====important thing:
                            player1 = javax.media.Manager.createPlayer(clonedDS);
    //=====
              if (player1 == null)
                  return;
              player1.addControllerListener(this);
              player1.realize();
              // Notify intialize() that a new stream had arrived.
              synchronized (dataSync) {
                  dataReceived = true;
                  dataSync.notifyAll();
             } catch (Exception e) {
              System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
              return;
         else if (evt instanceof StreamMappedEvent) {
              if (stream != null && stream.getDataSource() != null) {
              DataSource ds = stream.getDataSource();
              // Find out the formats.
              RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
              System.err.println("  - The previously unidentified stream ");
              if (ctl != null)
                  System.err.println("      " + ctl.getFormat());
              System.err.println("      had now been identified as sent by: " + participant.getCNAME());
         else if (evt instanceof ByeEvent) {
              System.err.println("  - Got \"bye\" from: " + participant.getCNAME());
          player1.close();
            manager.dispose();
        }

    I wanted to show the same video stream on 2 panels at the same time. The panels are on 2 different Tabs of TabbedPane.
    So I done some kind of switch:
    - when user change tab, I change vievport from one panel to another. This works gr8, but I need to record some received video on the same time when user watch it.
    I find some code to record - this works on single machine, but now, when I have cloned dataSource I supposed to be able to record received video, but guess what: it doesn't work.
    Code of recording part:
               DataSource ds2; // I cloned this the same as I posted earlier
                PushBufferStream pbs;
         Vector camImgSize = new Vector();
         Vector camCapDevice = new Vector();
         Vector camCapFormat = new Vector();
         int camFPS;
         int camImgSel;
         Processor processor = null;
         DataSink datasink = null;
        public void record()
            fetchDeviceFormats();
              camImgSel=0;     // first format, or otherwise as desired
              camFPS = 30;     // framerate
              // Setup data source
              fetchDeviceDataSource();
              createPBDSource();
              createProcessor(ds2); // i'm using cloned datasource
              startCapture();
              try{Thread.sleep(20000);}catch(Exception e){}     // 20 seconds
              stopCapture();
         boolean fetchDeviceFormats()
              Vector deviceList = CaptureDeviceManager.getDeviceList(new VideoFormat(null));
              CaptureDeviceInfo CapDevice = null;
              Format CapFormat = null;
              String type = "N/A";
              CaptureDeviceInfo deviceInfo=null;boolean VideoFormatMatch=false;
              for(int i=0;i<deviceList.size();i++)
                   // search for video device
                   deviceInfo = (CaptureDeviceInfo)deviceList.elementAt(i);
                   if(deviceInfo.getName().indexOf("vfw:")<0)continue;
                   Format deviceFormat[] = deviceInfo.getFormats();
                   for (int f=0;f<deviceFormat.length;f++)
                        if(deviceFormat[f] instanceof RGBFormat)type="RGB";
                        if(deviceFormat[f] instanceof YUVFormat)type="YUV";
                        if(deviceFormat[f] instanceof JPEGFormat)type="JPG";
                        Dimension size = ((VideoFormat)deviceFormat[f]).getSize();
                        camImgSize.addElement(type+" "+size.width+"x"+size.height);
                        CapDevice = deviceInfo;
                        camCapDevice.addElement(CapDevice);
                        //System.out.println("Video device = " + deviceInfo.getName());
                        CapFormat = (VideoFormat)deviceFormat[f];
                        camCapFormat.addElement(CapFormat);
                        //System.out.println("Video format = " + deviceFormat[f].toString());
                        VideoFormatMatch=true;     // at least one
              if(VideoFormatMatch==false)
                   if(deviceInfo!=null)System.out.println(deviceInfo);
                   System.out.println("Video Format not found");
                   return false;
              return true;
         * Finds a camera and sets it up
         void fetchDeviceDataSource() //I test it on localhost so I don't change it
              CaptureDeviceInfo CapDevice = (CaptureDeviceInfo)camCapDevice.elementAt(camImgSel);
              System.out.println("Video device = " + CapDevice.getName());
              Format CapFormat = (Format)camCapFormat.elementAt(camImgSel);
              System.out.println("Video format = " + CapFormat.toString());
              try
                   // ensures 30 fps or as otherwise preferred, subject to available cam rates but this is frequency of windows request to stream
                   FormatControl formCont=((CaptureDevice)ds2).getFormatControls()[0];
                   VideoFormat formatVideoNew = new VideoFormat(null,null,-1,null,(float)camFPS);
                   formCont.setFormat(CapFormat.intersects(formatVideoNew));
              catch(Exception e){}
         * Gets a stream from the camera (and sets debug)
         void createPBDSource()
              try
                   pbs=((PushBufferDataSource)ds2).getStreams()[0];
              catch(Exception e){}
         public void createProcessor(DataSource datasource)
              FileTypeDescriptor ftd = new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO);
              Format[] formats = new Format[] {new VideoFormat(VideoFormat.INDEO50)};
              ProcessorModel pm = new ProcessorModel(datasource, formats, ftd);
              try
                   processor = Manager.createRealizedProcessor(pm);
              catch(Exception me)
                   System.out.println(me);
                   // Make sure the capture devices are released
                   datasource.disconnect();
                   return;
         private void startCapture()
              // Get the processor's output, create a DataSink and connect the two.
              DataSource outputDS = processor.getDataOutput();
              try
                   MediaLocator ml = new MediaLocator("file:capture.avi");
                   datasink = Manager.createDataSink(outputDS, ml);
                   datasink.open();
                   datasink.start();
              }catch (Exception e)
                   System.out.println(e);
              processor.start();
              System.out.println("Started saving...");
         private void pauseCapture()
              processor.stop();
         private void resumeCapture()
              processor.start();
         private void stopCapture()
              // Stop the capture and the file writer (DataSink)
              processor.stop();
              processor.close();
              datasink.close();
              processor = null;
              System.out.println("Done saving.");
         }I run method record() from gui, after I received stream.
    IMPORTANT:
         on:           processor.close();
    I have an exception:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.sun.media.multiplexer.video.AVIMux.writeFooter(AVIMux.java:827)
    at com.sun.media.multiplexer.BasicMux.close(BasicMux.java:142)
    at com.sun.media.BasicMuxModule.doClose(BasicMuxModule.java:172)
    at com.sun.media.PlaybackEngine.doClose(PlaybackEngine.java:872)
    at com.sun.media.BasicController.close(BasicController.java:261)
    at com.sun.media.BasicPlayer.doClose(BasicPlayer.java:229)
    at com.sun.media.BasicController.close(BasicController.java:261)
    at jmonitorserver.engine.Po&#322;&#261;czenie.stopCapture(Po&#322;&#261;czenie.java:684)
    And the video file have 0kb, even during recording
    datasource ds2 is not null.
    any idea?

  • Codes for audio video receiver class

    I am currently writting an audio and video receiver for my project based on AVReceive3, it works but i can only get Video only, everything seems to be normal, i dont see why i am not getting audio. My transmitter is working fine and sending both streams.
    If anyone can spot the error or mistake i a making, pleaase let me know as soon as possible.
    my email address is [email protected]
    public class AudVidReceive extends Frame implements ActionListener,ReceiveStreamListener,SessionListener,ControllerListener
    // Input MediaLocator
    // Can be a file or http or capture source
    private MediaLocator alocator;
    MediaLocator vlocator,vloct,aloct;
    private String ipAddress;
    private int portBase;
    Button transtop,transtart,recstop,recstart;
    Component controlPanel, visualComponent;
    //For Receiving Media Stream
    String sessions[] = null;
    SessionManager mgrs[] = null;
    Vector playerWindows = null;
    boolean dataReceived = false;
    Object dataSync = new Object();
    private Processor processor = null;
    Player player=null;
    Format fmt=null;
    private SessionManager rtpMgrs[];
    private DataSource dataOutput = null;
    DataSource ads=null;
    DataSource vds=null;
    DataSource source[];
    DataSource m=null;
    public AudVidReceive()
    super("Audio Video Receive");
    recstart=new Button("StartReceiving");
    //recstop=new Button("Stop Receiving");
    add(recstart);
    recstart.setBounds(80,250,100,30);
    recstart.addActionListener(this);
    setLayout(null);
    setSize(400,300);
    setVisible(true);
    //this.sessions=sessions;
    public void actionPerformed(ActionEvent e)
    Button b=(Button)e.getSource();
    String ac=e.getActionCommand();
    if(ac.equalsIgnoreCase("StartReceiving"))
    boolean flag;
    boolean st=initialize();
    if(!st)
    System.err.println("Failed to Realize the Sessions ");
    System.exit(-1);
    flag=isDone();
    try{
    while(!flag)
    Thread.sleep(1000);
    }catch(Exception e1)
    e1.printStackTrace();
    //Initialize the Session for Receiving the Incomming Stream
    protected boolean initialize() {
    try {
    InetAddress ipAddr;
    SessionAddress localAddr = new SessionAddress();
    SessionAddress destAddr;
    String sessions[]={"192.168.2.143/42060"};
    mgrs = new com.sun.media.rtp.RTPSessionMgr[sessions.length];
    playerWindows = new Vector();
    SessionLabel session;
    // Open the RTP sessions.
    for (int i = 0; i < sessions.length; i++) {
    // Parse the session addresses.
    try {
    session = new SessionLabel(sessions);
    } catch (IllegalArgumentException e) {
    System.err.println("Failed to parse the session address given: " + sessions[i]);
    return false;
    System.err.println(" - Open RTP session for: addr: " + session.addr + " port: " + session.port + " ttl: " + session.ttl);
    mgrs[i] = new com.sun.media.rtp.RTPSessionMgr();
    mgrs[i].addSessionListener(this);
    mgrs[i].addReceiveStreamListener(this);
    ipAddr = InetAddress.getByName(session.addr);
    destAddr = new SessionAddress(ipAddr, session.port,
    ipAddr, session.port+1);
    mgrs[i].initSession(localAddr, getSDES(mgrs[i]), .05, .25);
    // You can try out some other buffer size to see
    // if you can get better smoothness.
    BufferControl bc = (BufferControl)mgrs[i].getControl("javax.media.control.BufferControl");
    if (bc != null)
    bc.setBufferLength(350);
    mgrs[i].startSession(destAddr, session.ttl, null);
    } catch (Exception e){
    System.err.println("Cannot create the RTP Session: " + e.getMessage());
    return false;
    // Wait for data to arrive before moving on.
    long then = System.currentTimeMillis();
    long waitingPeriod = 120000; // wait for a maximum of 30 secs.
    try{
    synchronized (dataSync)
    while (!dataReceived && System.currentTimeMillis() - then < waitingPeriod) {
    if (!dataReceived)
    System.err.println(" - Waiting for RTP data to arrive...");
    dataSync.wait(1000);
    }catch (Exception e) {}
    if (!dataReceived) {
    System.err.println("No RTP data was received.");
    close();
    return false;
    return true;
    * Find out the host info.
    String cname = null;
    private SourceDescription[] getSDES(SessionManager mgr)
    SourceDescription[] desclist = new SourceDescription[3];
    if (cname == null)
    cname = mgr.generateCNAME();
    desclist[0] = new
    SourceDescription(SourceDescription.SOURCE_DESC_NAME,
    System.getProperty("user.name"),
    1,
    false);
    desclist[1] = new
    SourceDescription(SourceDescription.SOURCE_DESC_CNAME,
    cname,
    1,
    false);
    desclist[2] = new
    SourceDescription(SourceDescription.SOURCE_DESC_TOOL,
    "AVReceive powered by JMF",
    1,
    false);
    return desclist;
    //Check Player window sizing
    public boolean isDone() {
    return playerWindows.size() == 0;
    * Close the players and the session managers.
    protected void close()
    for (int i = 0; i < playerWindows.size(); i++)
    try {
    ((PlayerWindow)playerWindows.elementAt(i)).close();
    } catch (Exception e) {}
    playerWindows.removeAllElements();
    // close the RTP session.
    for (int i = 0; i < mgrs.length; i++) {
    if (mgrs[i] != null) {
    mgrs[i].closeSession("Closing session from AudVidReceive");
    mgrs[i] = null;
    //Find the player
    PlayerWindow find(Player p) {
    for (int i = 0; i < playerWindows.size(); i++) {
    PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
    if (pw.player == p)
    return pw;
    return null;
    //Find whether the Player is receiving the Stream
    PlayerWindow find(ReceiveStream strm) {
    for (int i = 0; i < playerWindows.size(); i++) {
    PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
    if (pw.stream == strm)
    return pw;
    return null;
    * SessionListener.
    public synchronized void update(SessionEvent evt) {
    if (evt instanceof NewParticipantEvent) {
    Participant p = ((NewParticipantEvent)evt).getParticipant();
    System.err.println(" - A new participant had just joined: " + p.getCNAME());
    * ReceiveStreamListener
    public synchronized void update( ReceiveStreamEvent evt) {
    SessionManager mgr = (SessionManager)evt.getSource();
    Participant participant = evt.getParticipant(); // could be null.
    ReceiveStream stream = evt.getReceiveStream(); // could be null.
    if (evt instanceof RemotePayloadChangeEvent) {
    System.err.println(" - Received an RTP PayloadChangeEvent.");
    System.err.println("Sorry, cannot handle payload change.");
    System.exit(0);
    else if (evt instanceof NewReceiveStreamEvent) {
    try {
    stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
    if (ctl != null){
    System.err.println(" - Recevied new RTP stream: " + ctl.getFormat());
    } else
    System.err.println(" - Recevied new RTP stream");
    if (participant == null)
    System.err.println(" The sender of this stream had yet to be identified.");
    else {
    System.err.println(" The stream comes from: " + participant.getCNAME());
    // create a player by passing datasource to the Media Manager
    Player p = javax.media.Manager.createPlayer(ds);
    if (p == null)
    return;
    p.addControllerListener(this);
    p.realize();
    PlayerWindow pw = new PlayerWindow(p, stream);
    playerWindows.addElement(pw);
    // Notify intialize() that a new stream had arrived.
    synchronized (dataSync) {
    dataReceived = true;
    dataSync.notifyAll();
    } catch (Exception e) {
    System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
    return;
    }//above catch closing if
    else if (evt instanceof StreamMappedEvent) {
    if (stream != null && stream.getDataSource() != null) {
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
    System.err.println(" - The previously unidentified stream ");
    if (ctl != null)
    System.err.println(" " + ctl.getFormat());
    System.err.println(" had now been identified as sent by: " + participant.getCNAME());
    else if (evt instanceof ByeEvent) {
    System.err.println(" - Got \"bye\" from: " + participant.getCNAME());
    PlayerWindow pw = find(stream);
    if (pw != null) {
    pw.close();
    playerWindows.removeElement(pw);
    }// end of this method
    * ControllerListener for the Players.
    public synchronized void controllerUpdate(ControllerEvent ce) {
    Player p = (Player)ce.getSourceController();
    if (p == null)
    return;
    // Get this when the internal players are realized.
    if (ce instanceof RealizeCompleteEvent) {
    PlayerWindow pw = find(p);
    if (pw == null) {
    // Some strange happened.
    System.err.println("Internal error!");
    System.exit(-1);
    pw.initialize();
    pw.setVisible(true);
    p.start();
    if (ce instanceof ControllerErrorEvent) {
    p.removeControllerListener(this);
    PlayerWindow pw = find(p);
    if (pw != null) {
    pw.close();
    playerWindows.removeElement(pw);
    System.err.println("AVReceive internal error: " + ce);
    * A utility class to parse the session addresses.
    class SessionLabel {
    public String addr = null;
    public int port;
    public int ttl = 1;
    SessionLabel(String session) throws IllegalArgumentException {
    int off;
    String portStr = null, ttlStr = null;
    if (session != null && session.length() > 0) {
    while (session.length() > 1 && session.charAt(0) == '/')
    session = session.substring(1);
    // Now see if there's a addr specified.
    off = session.indexOf('/');
    if (off == -1) {
    if (!session.equals(""))
    addr = session;
    } else {
    addr = session.substring(0, off);
    session = session.substring(off + 1);
    // Now see if there's a port specified
    off = session.indexOf('/');
    if (off == -1) {
    if (!session.equals(""))
    portStr = session;
    } else {
    portStr = session.substring(0, off);
    session = session.substring(off + 1);
    // Now see if there's a ttl specified
    off = session.indexOf('/');
    if (off == -1) {
    if (!session.equals(""))
    ttlStr = session;
    } else {
    ttlStr = session.substring(0, off);
    if (addr == null)
    throw new IllegalArgumentException();
    if (portStr != null) {
    try {
    Integer integer = Integer.valueOf(portStr);
    if (integer != null)
    port = integer.intValue();
    } catch (Throwable t) {
    throw new IllegalArgumentException();
    } else
    throw new IllegalArgumentException();
    if (ttlStr != null) {
    try {
    Integer integer = Integer.valueOf(ttlStr);
    if (integer != null)
    ttl = integer.intValue();
    } catch (Throwable t) {
    throw new IllegalArgumentException();
    * GUI classes for the Player.
    class PlayerWindow extends Frame {
    Player player;
    ReceiveStream stream;
    PlayerWindow(Player p, ReceiveStream strm) {
    player = p;
    stream = strm;
    public void initialize() {
    add(new PlayerPanel(player));
    public void close() {
    player.close();
    setVisible(false);
    dispose();
    public void addNotify() {
    super.addNotify();
    pack();
    * GUI classes for the Player.
    class PlayerPanel extends Panel {
    Component vc, cc;
    PlayerPanel(Player p) {
    setLayout(new BorderLayout());
    if ((vc = p.getVisualComponent()) != null)
    add("Center", vc);
    if ((cc = p.getControlPanelComponent()) != null)
    add("South", cc);
    public Dimension getPreferredSize() {
    int w = 0, h = 0;
    if (vc != null) {
    Dimension size = vc.getPreferredSize();
    w = size.width;
    h = size.height;
    if (cc != null) {
    Dimension size = cc.getPreferredSize();
    if (w == 0)
    w = size.width;
    h += size.height;
    if (w < 160)
    w = 160;
    return new Dimension(w, h);
    public static void main(String [] args) {
    Format fmt = null;
    int i = 0;
    AudVidReceive at1 = new AudVidReceive();
    System.err.println("Start Receiving incoming Streams ");
    try {
    Thread.currentThread().sleep(60000);
    } catch (InterruptedException ie) {
    ie.printStackTrace();

    I have to use RTP and RTSP for transferring the
    audio/video streams in real time.
    How I can sen and receive RTP packets.
    How can I make the RTP Player.
    What is the role of JMF in it.
    Please suggest me and provide me the codes if
    possible.
    Thanks alot
    shobhit vermaThere are two ways using which you can send and recieve packets using rtp. One without using the SessionManager and the other with.
    1.) Not using the SessionManager makes things easy for you but it offers very little flexibility to you. You can do this by just specifying a medialocator pointing to the specific url
    2.) Using the SessionManager is what is usually suggested. This process is more complex. First you have to instantiate a RTPSessionMgr to a SessionManager reference using which you can send and receive streams to and from the network. The process is more involved than this and is suggest you read some tutorials to get a better understanding, than me explaining to you the entire process.
    Message was edited by:
    qUesT_foR_knOwLeDge

  • Transmit and receive from the same ip address?

    Helpers:
    We 've been using transmit/Receive for a while, I read all the discussions. No one seem really know does the transmit send to a destination IP address and the destination receive from the same IP or the IP address the sender send from?
    like sender send from: java Transmitter 123.4.3.162 5000
    receiver receive from: java Receive 123.4.3.162 5000
    or sender send from: java Transmitter 123.4.3.162 5000
    receiver receive from: java Receive 10.118.5.162 5000
    I think the frist one is correct, does anyone has clear idea and experience about it.
    Desperate coder!

    Receiver code is as follows
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.media.*;
    import javax.media.rtp.*;
    import javax.media.rtp.event.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.AudioFormat;
    import javax.media.format.VideoFormat;
    import javax.media.Format;
    import javax.media.format.FormatChangeEvent;
    import javax.media.control.BufferControl;
    public class AVReceive2 implements ReceiveStreamListener, SessionListener,ControllerListener
    String sessions[] = null;
    RTPManager mgrs[] = null;
    Vector playerWindows = null;
    boolean dataReceived = false;
    Object dataSync = new Object();
    public AVReceive2(String sessions[])
              this.sessions = sessions;
    protected boolean initialize()
    try
              InetAddress ipAddr;
         SessionAddress localAddr = new SessionAddress();
              SessionAddress destAddr;
              mgrs = new RTPManager[sessions.length];
              playerWindows = new Vector();
              SessionLabel session;
              for (int i = 0; i < sessions.length; i++)
                   try
         session = new SessionLabel(sessions);
              catch (IllegalArgumentException e)
         System.err.println("Failed to parse the session address given: " + sessions[i]);
                        return false;
    System.err.println(" - Open RTP session for: addr: " + session.addr + " port: " + session.port + " ttl: " + session.ttl);
         mgrs[i] = (RTPManager) RTPManager.newInstance();
         mgrs[i].addSessionListener(this);
         mgrs[i].addReceiveStreamListener(this);
         ipAddr = InetAddress.getByName(session.addr);
              if( ipAddr.isMulticastAddress())
    // local and remote address pairs are identical:
    localAddr= new SessionAddress( ipAddr,session.port,session.ttl);
    destAddr = new SessionAddress( ipAddr,session.port,session.ttl);
                        else
    localAddr= new SessionAddress( InetAddress.getLocalHost(),session.port);
    destAddr = new SessionAddress( ipAddr, session.port);
              mgrs[i].initialize( localAddr);
    BufferControl bc = (BufferControl)mgrs[i].getControl("javax.media.control.BufferControl");
                        if (bc != null)
              bc.setBufferLength(350);
                   mgrs[i].addTarget(destAddr);
              catch (Exception e)
    System.err.println("Cannot create the RTP Session: " + e.getMessage());
    return false;
         long then = System.currentTimeMillis();
    long waitingPeriod = 30000; // wait for a maximum of 30 secs.
              try
              synchronized (dataSync)
    while (!dataReceived && System.currentTimeMillis() - then < waitingPeriod)
                        if (!dataReceived)
                                  System.err.println(" - Waiting for RTP data to arrive...");
                        dataSync.wait(1000);
              catch (Exception e) {}
              if (!dataReceived)
    System.err.println("No RTP data was received.");
              close();
              return false;
    return true;
    public boolean isDone()
              return playerWindows.size() == 0;
    protected void close()
              for (int i = 0; i < playerWindows.size(); i++)
              try
         ((PlayerWindow)playerWindows.elementAt(i)).close();
              catch (Exception e) {}
              playerWindows.removeAllElements();
         // close the RTP session.
              for (int i = 0; i < mgrs.length; i++)
              if (mgrs[i] != null)
    mgrs[i].removeTargets( "Closing session from AVReceive2");
    mgrs[i].dispose();
                        mgrs[i] = null;
    PlayerWindow find(Player p)
              for (int i = 0; i < playerWindows.size(); i++)
              PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
              if (pw.player == p)
                        return pw;
              return null;
    PlayerWindow find(ReceiveStream strm)
              for (int i = 0; i < playerWindows.size(); i++)
              PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
              if (pw.stream == strm)
                        return pw;
              return null;
    public synchronized void update(SessionEvent evt)
              if (evt instanceof NewParticipantEvent)
         Participant p = ((NewParticipantEvent)evt).getParticipant();
    System.err.println(" - A new participant had just joined: " + p.getCNAME());
    public synchronized void update( ReceiveStreamEvent evt)
         RTPManager mgr = (RTPManager)evt.getSource();
    Participant participant = evt.getParticipant();     // could be null.
    ReceiveStream stream = evt.getReceiveStream(); // could be null.
              if (evt instanceof RemotePayloadChangeEvent)
    System.err.println(" - Received an RTP PayloadChangeEvent.");
    System.err.println("Sorry, cannot handle payload change.");
              System.exit(0);
              else
              if (evt instanceof NewReceiveStreamEvent)
              try {
    stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
    DataSource ds = stream.getDataSource();
              // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
                        if (ctl != null)
    System.err.println(" - Recevied new RTP stream: " + ctl.getFormat());
                        else
    System.err.println(" - Recevied new RTP stream");
                        if (participant == null)
    System.err.println(" The sender of this stream had yet to be identified.");
                        else
    System.err.println(" The stream comes from: " + participant.getCNAME());
    // create a player by passing datasource to the Media Manager
    Player p = javax.media.Manager.createPlayer(ds);
                        if (p == null)
                        return;
                   p.addControllerListener(this);
                        p.realize();
         PlayerWindow pw = new PlayerWindow(p, stream);
         playerWindows.addElement(pw);
                   synchronized (dataSync)
                        dataReceived = true;
                        dataSync.notifyAll();
              catch (Exception e)
         System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
                        return;
              else
              if (evt instanceof StreamMappedEvent)
                   if (stream != null && stream.getDataSource() != null)
                        DataSource ds = stream.getDataSource();
              // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
         System.err.println(" - The previously unidentified stream ");
                        if (ctl != null)
         System.err.println(" " + ctl.getFormat());
         System.err.println(" had now been identified as sent by: " + participant.getCNAME());
              else
              if (evt instanceof ByeEvent)
    System.err.println(" - Got \"bye\" from: " + participant.getCNAME());
              PlayerWindow pw = find(stream);
              if (pw != null)
                        pw.close();
              playerWindows.removeElement(pw);
    public synchronized void controllerUpdate(ControllerEvent ce)
              Player p = (Player)ce.getSourceController();
              if (p == null)
              return;
         // Get this when the internal players are realized.
              if (ce instanceof RealizeCompleteEvent)
              PlayerWindow pw = find(p);
              if (pw == null)
              // Some strange happened.
              System.err.println("Internal error!");
                        System.exit(-1);
              pw.initialize();
              pw.setVisible(true);
              p.start();
              if (ce instanceof ControllerErrorEvent)
              p.removeControllerListener(this);
              PlayerWindow pw = find(p);
              if (pw != null)
                        pw.close();
              playerWindows.removeElement(pw);
         System.err.println("AVReceive2 internal error: " + ce);
    class SessionLabel
              public String addr = null;
              public int port;
              public int ttl = 1;
    SessionLabel(String session) throws IllegalArgumentException
              int off;
              String portStr = null, ttlStr = null;
              if (session != null && session.length() > 0)
         while (session.length() > 1 && session.charAt(0) == '/')
              session = session.substring(1);
              // Now see if there's a addr specified.
                        off = session.indexOf('/');
                        if (off == -1)
                        if (!session.equals(""))
                   addr = session;
                        else
              addr = session.substring(0, off);
              session = session.substring(off + 1);
              // Now see if there's a port specified
              off = session.indexOf('/');
                        if (off == -1)
                        if (!session.equals(""))
                        portStr = session;
                             else
              portStr = session.substring(0, off);
              session = session.substring(off + 1);
              // Now see if there's a ttl specified
                                  off = session.indexOf('/');
                                  if (off == -1)
                                  if (!session.equals(""))
                                            ttlStr = session;
                   else
              ttlStr = session.substring(0, off);
              if (addr == null)
         throw new IllegalArgumentException();
              if (portStr != null)
                        try {
              Integer integer = Integer.valueOf(portStr);
                        if (integer != null)
                                  port = integer.intValue();
              catch (Throwable t)
              throw new IllegalArgumentException();
              else
              throw new IllegalArgumentException();
              if (ttlStr != null)
                        try {
              Integer integer = Integer.valueOf(ttlStr);
                        if (integer != null)
                   ttl = integer.intValue();
                        catch (Throwable t)
              throw new IllegalArgumentException();
    class PlayerWindow extends Frame {
         Player player;
         ReceiveStream stream;
         PlayerWindow(Player p, ReceiveStream strm) {
         player = p;
         stream = strm;
         public void initialize() {
         add(new PlayerPanel(player));
         public void close() {
         player.close();
         setVisible(false);
         dispose();
         public void addNotify() {
         super.addNotify();
         pack();
    class PlayerPanel extends Panel {
         Component vc, cc;
         PlayerPanel(Player p) {
         setLayout(new BorderLayout());
         if ((vc = p.getVisualComponent()) != null)
              add("Center", vc);
         if ((cc = p.getControlPanelComponent()) != null)
              add("South", cc);
         public Dimension getPreferredSize() {
         int w = 0, h = 0;
         if (vc != null) {
              Dimension size = vc.getPreferredSize();
              w = size.width;
              h = size.height;
         if (cc != null) {
              Dimension size = cc.getPreferredSize();
              if (w == 0)
              w = size.width;
              h += size.height;
         if (w < 160)
              w = 160;
         return new Dimension(w, h);
    public static void main(String args[])
              String[] argv = new String[2];
              argv[0] = "100.210.0.220/42050";
              argv[1] = "100.210.0.220/4002";
              AVReceive2 avReceive = new AVReceive2(argv);
              if (!avReceive.initialize())
         System.err.println("Failed to initialize the sessions.");
              System.exit(-1);
              try {
              while (!avReceive.isDone())
                        Thread.sleep(1000);
              } catch (Exception e) {}
              System.err.println("Exiting AVReceive2");

  • Memory Leak, Receiver Got Null Message & Consumer limit exceeded on destina

    When running program that adds an Object message to a JMS queue and then recieves it. I get the following.
    1) interminitent NULL messages recieved.
    2) jms.JMSException: [C4073]: Consumer limit exceeded on destination interactionQueueDest. Even though only one receiver can be receiving via the supplied program.
    3) After many message are added to the queue 1000's the Message Queue goes to Out Of Memory exception. It should swap to disk!!
    STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
    RUN this program via a JSP call in the application server.
    JSP
    <%@ page language="java" import="jms.*"%>
    <html>
    <head>
    <title>Leak Memory</title>
    </head>
    <body>
    <hr/>
    <h1>Leak Memory</h1>
    <%
       LeakMemory leakMemory = new LeakMemory();
       leakMemory.runTest(10000,1000);
      // NOTE will brake but slower with setting leakMemory.runTest(10000,100);
    %>JMS resources must be created:
    jms/queueConnectionFactory
    jms/interactionQueue
    must be created first.
    Class:
    package jms;
    import javax.naming.*;
    import javax.jms.*;
    public class LeakMemory implements Runnable {
      private QueueConnectionFactory queueConnectionFactory = null;
      private Queue interactionQueue = null;
      private boolean receiverRun = true;
      private QueueConnection queueConnection;
      private int totalMessageInQueue = 0;
      public LeakMemory() {
        init();
       * initialize queues
      public void init(){
        try {
          InitialContext context = new InitialContext();
          this.queueConnectionFactory = (QueueConnectionFactory)context.lookup("jms/queueConnectionFactory");
          this.interactionQueue = (Queue) context.lookup("jms/interactionQueue");
        catch (NamingException ex) {
          printerError(ex);
      public void runTest(int messageCount, int messageSize){
        this.receiverRun = true;
        Thread receiverThread = new Thread(this);
        receiverThread.start();
        for (int i = 0; i < messageCount; i++) {
            StringBuffer messageToSend = new StringBuffer();
            for (int ii = 0; ii < messageSize; ii++) {
              messageToSend.append("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
            QueueConnection queueConnectionAdder = null;
            QueueSession queueInteractionSession = null;
            QueueSender interactionQueueSender = null;
            try {
                //Get a queue connection
                queueConnectionAdder = this.getQueueConnection();
                queueInteractionSession = queueConnectionAdder.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                interactionQueueSender = queueInteractionSession.createSender(this.interactionQueue);
                ObjectMessage objectMessage = queueInteractionSession.createObjectMessage(messageToSend);
                objectMessage.setStringProperty("PROPERTY", "" + System.currentTimeMillis());
                //Send object
                interactionQueueSender.send(objectMessage,DeliveryMode.PERSISTENT,5,0);
                totalMessageInQueue++;
                //Close Resources
                interactionQueueSender.close();
                queueInteractionSession.close();
                interactionQueueSender = null;
                queueInteractionSession = null;
            } catch (JMSException ex) {
               printerError(ex);
       * run
      public void run()  {
        while(this.receiverRun){
                try {
                  QueueSession interactionQueueSession = this.getQueueConnection().createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
                  QueueReceiver queueReceiver = interactionQueueSession.createReceiver(this.interactionQueue);
                  ObjectMessage message = (ObjectMessage)queueReceiver.receive(100);
                  if(message != null){
                    StringBuffer messageRecived = (StringBuffer)message.getObject();
                    //Simulate Doing Something
                    synchronized (this) {
                      try {
                        Thread.sleep(400);
                      catch (InterruptedException ex1) {
                        //Can Safely be ignored
                    message.acknowledge();
                    totalMessageInQueue--;
                  } else {
                    printerError(new Exception("Receiver Got Null Message"));
                  queueReceiver.close();
                  interactionQueueSession.close();
                  queueReceiver = null;
                  interactionQueueSession = null;
                catch (JMSException ex) {
                  printerError(ex);
        * Get's the queue Connection and starts it
        * @return QueueConnection The queueConnection
       public synchronized QueueConnection getQueueConnection(){
           if (this.queueConnection == null) {
             try {
               this.queueConnection = this.queueConnectionFactory.createQueueConnection();
               this.queueConnection.start();
             catch (JMSException ex) {
               printerError(ex);
         return this.queueConnection;
       private void printerError(Exception ex){
         System.err.print("ERROR Exception totalMessageInQueue = " + this.totalMessageInQueue + "\n");
         ex.printStackTrace();
    }Is there something wrong with the way I'm working with JMS or is it just this unreliable in Sun App Server 7 Update 3 on windows?

    1) interminitent NULL messages recieved.Thanks that explains the behavior. It was wierd getting null messages when I know there is messages in the queue.
    2) jms.JMSException: [C4073]: Consumer limit exceeded
    on destination interactionQueueDest. Even though only
    one receiver can be receiving via the supplied
    program. No other instances, Only this program. Try it yourself!! It works everytime on Sun Application Server 7 update 2 & 3
    heres the broker dump at that error point
    [14/Apr/2004:12:51:47 BST] [B1065]: Accepting: [email protected]:3211->admin:3205. Count=1
    [14/Apr/2004:12:51:47 BST] [B1066]:   Closing: [email protected]:3211->admin:3205. Count=0
    [14/Apr/2004:12:52:20 BST] [B1065]: Accepting: [email protected]:3231->jms:3204. Count=1 [14/Apr/2004:12:53:31 BST] WARNING [B2009]: Creation of consumer  from connection [email protected]:3231 on destination interactionQueueDest failed:
    B4006: com.sun.messaging.jmq.jmsserver.util.BrokerException: [B4006]: Unable to attach to queue queue:single:interactionQueueDest: a primary queue is already active
    3) After many message are added to the queue 1000's
    the Message Queue goes to Out Of Memory exception. It
    should swap to disk!!The broker runs out of memory. Version in use
    Sun ONE Message Queue                   Copyright 2002
    Version:  3.0.1 SP2 (Build 4-a)              Sun Microsystems, Inc.
    Compile:  Fri 07/11/2003         All Rights ReservedOut of memory snippet
    [14/Apr/2004:13:08:28 BST] [B1089]: In low memory condition, Broker is attempting to free up resources
    [14/Apr/2004:13:08:28 BST] [B1088]: Entering Memory State [B0022]: YELLOW from previous state [B0021]: GREEN  - current memory is 118657K, 60% of total memory
    [14/Apr/2004:13:08:38 BST] WARNING [B2075]: Broker ran out of memory before the passed in VM maximum (-Xmx) 201326592 b,  lowering max to currently allocated memory (200431976 b ) and trying to recover [14/Apr/2004:13:08:38 BST] [B1089]: In low memory condition, Broker is attempting to free up resources
    [14/Apr/2004:13:08:38 BST] [B1088]: Entering Memory State [B0024]:  RED  from previous state [B0022]: YELLOW - current memory is 128796K, 99% of total memory [14/Apr/2004:13:08:38 BST] ERROR [B3008]: Message 2073-192.168.0.50(80:d:b6:c4:d6:73)-3319-1081944517772 exists in the store already [14/Apr/2004:13:08:38 BST] WARNING [B2011]: Storing of JMS message from IMQConn[AUTHENTICATED,[email protected]:3319,jms:3282] failed:
    com.sun.messaging.jmq.jmsserver.util.BrokerException: Message 2073-192.168.0.50(80:d:b6:c4:d6:73)-3319-1081944517772 exists in the store already
    [14/Apr/2004:13:08:38 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:38 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:39 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:39 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:39 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:39 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:40 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:40 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:40 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:40 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:41 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:42 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:42 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:42 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:42 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:43 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:43 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:43 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:43 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:44 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:44 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:44 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:45 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:45 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:46 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:46 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:47 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:47 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:47 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:47 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:48 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:49 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:49 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:49 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:49 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:50 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:50 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:50 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:50 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:51 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:51 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:51 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:51 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:52 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:52 BST] WARNING [B2076]: Broker is rejecting new producers, because it is extremely low on memory
    [14/Apr/2004:13:08:53 BST] ERROR [B3107]: Attempt to free memory failed, taking more drastic measures : java.lang.OutOfMemoryError
    [14/Apr/2004:13:08:53 BST] ERROR unable to deal w/ error: 1
    [14/Apr/2004:13:08:53 BST] ERROR TRYING TO CLOSE [14/Apr/2004:13:08:53 BST] ERROR DONE CLOSING
    [14/Apr/2004:13:08:53 BST] [B1066]:   Closing: [email protected]:3319->jms:3282. Count=0

  • Broken pipe error in Sync Send JDBC Receiver:   Extremely Serious issue

    Hi forum,
    I have a serious error in a JDBC->XI--> JDBC scenario,
    Step1: I use a sender JDBC channel to select some distinct values from  a table say X, and update the same rows,
    Query SQL Statement: select distinct Branch from dbo.X where status = 0
    Update SQL statement: update dbo.X set Status = 2 where Status = 0
    Step 2: enter BPM
    Step 3: enter a loop
    Step 4:make a synchronous call to the same table X, to fetch some records,
    SQL query: select * from X where status = 0 and Branch = i; Update X set status = 9 where Branch = i
    Step 5: close loop,  this loop iterates for 5 or 6 times depending on i, which is no. of branches selected by the sender JDBC channel
    so all the calls are to the same table, same databsse(SQL Server)
    the problem is when this sync calls happens in the loop, it some times gives following error, which i se in RWB:
    <b>Error Unable to execute statement for table or stored procedure. 'X' (Structure 'STATEMENT_X') due to com.microsoft.sqlserver.jdbc.SQLServerException: An exception occurred during the DBComms.transmit operation. Exception:Broken pipe (errno:32). Context:(2217)</b>
    i have no way to trace the cause of the error, the database is perfect and the error logs in the SQL server shows no trace of any error,
    Note: It works sometimes
    i dont know whom to approach, pls help
    the issue is very very serious as its in production system,

    Hi Sudeep,
    SAP Note 846079 - XI 3.0 JDBC Receiver: # of Retries on SQL Error w/o Effect
    Please check the following SAP note also - 831162
    Some info which i found there and can be relevant in to your scenario.....
    Q: I am using a JDBC Receiver Adapter in conjunction with the  Lotus Domino Driver for JDBC perform an INSERT or UPDATE operation on a database. When sending a message to the receiver, the Adapter Monitoring shows the following error message:
    "java.sql.SQLException: [Lotus][Domino Driver for JDBC]Invalid cursor state"
    Is there a fix for this issue?
    A: To work around this JDBC driver problem, activate the Advanced Mode for the respective JDBC Receiver channel and configure the setting "Number of Retries of Database Transaction on SQL Error" to a value > 0. Additionally, make sure that the setting "Database Auto-Commit Enabled" is also active as the Lotus Domino Driver for JDBC does not support transactions.
    Apply note 846079 before configuring this scenario.
    Q: The TCP/IP connection to my database host is running over an unreliable network connection, i.e. the connection is sometimes interrupted. Consequently, I sporadically receive an SQLException regarding a closed connection in the system trace or audit log or the connection as well as the JDBC Adapter channel are hanging.
    How can I work around this connectivity issue?
    A: Enable the "Advanced Mode" for the respective JDBC Adapter channel and select the option "Disconnect from Database After Processing each Message".
    Note that this might put additional load on your DBMS due to the creation of a new database connection for each message.
    I dont have access to a database right now, so i am not able to check this.
    Also check the JDBC driver compatability as mentioned in the above note.
    Cheer's

  • HT3529 I have a message domain error1032 and I cannot receive messages on my iPad any ideas?

    I have just had a box come up in the middle of screen for yahoo password it does not recognise my password and therefore I can't receive emails any a
    Ideas.

    It's not that you can't use the subject field, but it is very unreliable when I try to use it. Sometimes the message send button will work and sometimes it won't.
    But the biggest reason to turn it off is so that you do not accidentally type your message in the subject field. You can type a subject in that field, but you still have to type the actual message in the space below the subject field.

  • Not receiving messages

    Smasung Galaxy S3 (GT-I9300)
    Android 4.3 (official)
    Skype 5.0.0.52727
    Today I turned on mobile data on my phone (I don't use it otherwise due to ridiculous costs) and started Skype (I run it usually over WiFi).
    I noticed that it receives messages only when in foreground. Otherwise minutes pass and there is no notification of any incoming messages.
    Only if I open the Skype app, does it detect new messages. But even that is unreliable. I takes up to a minute for messages to appear. It only works like expected (messages are detected with less than a second delay) when a conversartion with the sender is open.
    This makes Skype pretty much useless, as one has to guess that a message was sent and manually open Skype, also must know who sent it, and oopen a conversation with that contact.
    I use mostly default settings (both in Skype and system).
    Regards,
    David

    I'm having similar issues on my Nexus 5, Skype version 5.0.0.55107.
    Most of the time I'm connected to the wi-fi network, then I usually have no problems with recieving calls and messages immediately, but if I swith to a cellular network and mobile data, then messages come later or only when I open skype itself.
    By the way, I've noticed the problem almost went away when I checked "Show Skype status as an ongoing notification", before that it seemed that it only worked on the foreground, and when I switched to other apps or the screen turned off, it just went offline.

  • Why is the mail application so unreliable?

    I have made my move to a Mac laptop this year after being overrun with iOS devices in my house. The MacBook Air I have is an awesome machine. One of the main things I got it for is for business productivity. The simplest of things I should be able to do is communicate over email, but the native mail application is so unreliable it is embarrassing. I have a yahoo account that I was able to setup fine enough. Every time I send an email it is a gamble as to whether or not it is sent or not. That is unacceptable. The mail accounts I setup on my iOS devices seem to be bulletproof and it boggles my mind that the mail client on the Mac OS is so bad. I wasted time with the support lines on several occassions and all they could tell me is tht sometimes after I send an emal it can get stuck in between sending and getting off the yahoo server so there is no record it has been sent and no copy in drafts. What an awful answer. It has gotten to the point where the only way I am confident to use email is on my iPhone or through the web browser on the yahoo site. I am really unhappy about this and would like to know if other people see the same problem.

    I'm spending hours with the techies on my server, which is the cable company we contract with. First I kept getting the message that Mail didn't recognize the server but it would connect when I clicked Connect. Then it started letting me receive messages but not send. Now I can't do either, and the company has no help for me. I have run the disk utility verify and repair options and it tells me all is well.
    I don't want my emails anywhere on the web, just here at home. The cable techs have gone over and over the technicalities on their end and have concluded that Apple Mail is the problem. I find evidence of that in much online grumbling, but here I find only self defense.
    How could you help me?
    1. Admit that your software has bugs. Tell me some things I could try to get my email working again. I'm finding such protocol elsewhere on the web but it all seems to relate to earlier versions of OSX.
    2. Show me where I could upgrade to a less buggy version than 6.2. This is my second laptop in the past year (first one stolen) and each had different problems with Mail. The first one kept losing mail. Messages would come in and then be gone when I'd go to answer them. Important items I would not delete. That's not happening with this one -- it just keeps losing connection with my server.
    Please stop pretending that anyone who has problems with Mail is afflicted in some way. There are problems, and I'm very shocked that Apple, who used to be one of the good guys (at least in my book), seems to to be stuck on a policy of self righteousness. Guys, your halo is tarnished with Apple Mail -- time to realize that and cope.

  • Slow Boot, Unreliable WiFi, and Forced Shutdowns

    Ever since I got my iMac, I've been having the same problems quite consistently for over a year now. The WiFi used to randomly drop out (as many others had also reported), but that was fixed. Except an OS update or two later and it's back (although it's different and not quite as bad). Anyway, here are all of the problems I've been having:
    – iMac is slow to boot; sometimes it won't boot unless I unplug my Firewire cable. For a fully-upgraded iMac, it shouldn't take as long as it does (upwards of a minute). Sometimes, however, it won't boot at all. It will get stuck at a grey screen (or login screen when I have that set up) with the cursor visible. The computer will not continue to boot up or receive any input until I unplug my external Firewire hard drives.
    – WiFi is somewhat unreliable. At times, my internet connection completely drops out despite having a full-strength signal. Oddly, it usually happens right after I start to use the internet after having been away for a while. In other words, it works great when I'm not at the computer (if, for example, I use LogMeIn), but as soon as I sit down at the computer, I can visit one website before it drops out on me. I end up turning WiFi off and back on again and hope that it works.
    – Finally, I can't remember the last time I did a legitimate shutdown. Every single time I go to shut my computer down, it never does it by itself. If I let it do its thing, some app won't quit and will cancel shutdown. The only way I've been able to remedy the problem is by clicking Shut Down then force-quitting literally everything. I've read that the problem tends to be Mail as it tries to keep a connection with the mail servers, but it's been anything from App Store to Safari to iTunes. I have a problem report handy from when I last shut my computer down if that's worth posting.
    Thanks for taking the time to help me figure this out!
    Kevin Stauss

    Hello, Kevin,
    Bootup holding CMD+r, or the Option/alt key to boot from the Restore partition & use Disk Utility from there to Repair the Disk, then Repair Permissions.
    See if the Disk is issuing any S.M.A.R.T errors in Disk Utility...
    http://support.apple.com/kb/PH7029
    Open Activity Monitor in Applications>Utilities, select All Processes & sort on CPU%, any indications there?
    How much RAM & free space do you have also, click on the Memory & Disk Usage Tabs.
    Open Console in Utilities & see if there are any clues or repeating messages when this happens.
    In the Memory tab of Activity Monitor, are there a lot of Pageouts?

Maybe you are looking for