Hi Youness,<div><br></div><div>thank you for your suggestions.</div><div>You&#39;r right, the STUN/TURN server I was using had a connection limit. I installed the <a href="http://turnserver.org">turnserver.org</a> one in a public addressed machine.</div>

<div>I also changed the way how I was writing the candidates, setting those pointers to NULL.</div><div>ICE seems to be working properly now! :)</div><div><br></div><div>I have a question:</div><div>According to the example in <a href="http://nice.freedesktop.org/libnice/NiceAgent.html">http://nice.freedesktop.org/libnice/NiceAgent.html</a></div>

<div>we should be able to start sending messages after the signal new-selected-pair is fired. However, I tried it but no success:</div><div><div><font class="Apple-style-span" size="1">void</font></div><div><font class="Apple-style-span" size="1">cb_new_selected_pair (void)</font></div>

<div><font class="Apple-style-span" size="1">{</font></div><div><font class="Apple-style-span" size="1">  printf (&quot;cb_new_selected_pair\n&quot;);</font></div><div><font class="Apple-style-span" size="1">  nice_agent_send(agent, stream_id, NICE_COMPONENT_TYPE_RTP, strlen(&quot;Ola&quot;),&quot;Ola&quot;);</font></div>

<div><font class="Apple-style-span" size="1">}</font></div></div><div><br>That first message is never received. However, after &quot;a while&quot; I try to send again and it works. Do I have to wait for the other agent to be ready to receive?</div>

<div><br></div><div>Well, this is a checkpoint for me, but I must ask for another suggestion now.</div><div>I need to improve the way how the communication between agents is made (exchanging candidates/credentials, initiating p2p connections, etc...)</div>

<div>As I read in this thread <a href="http://lists.freedesktop.org/archives/nice/2010-August/000330.html">http://lists.freedesktop.org/archives/nice/2010-August/000330.html</a> , you wrote:</div>&quot;well, the serialization, if I understand what you mean, is how you send the candidates to the other side, right ? In that case, that&#39;s not part of the ICE methodology.. you can &#39;serialize&#39; the candidates/user/pass any way you want.. one method is to put it in the SDP of a SIP invite. You can also send it as an XML using Jingle&#39;s XEP over an XMPP connection.. it really all depends on what protocol is being used to connect to the server (SIP, XMPP, custom, other...). I&#39;ll let you decide on the best way to do that.&quot;<div>

<br></div><div>After doing some research, I feel a bit scared. That is a completely new world for me. Could you please point the &quot;simplest and most feasible&quot; solution for this problem? Should I choose SIP or XMPP?</div>

<div>libjingle, for example, presents a huge API...</div><div>Do you know any simple client, possibly allowing me to connect to an existing infrastructure (such as Google Talk), I could use for this trivial information exchange?</div>

<div><br></div><div>Thank you for your help.</div><div><br></div><div>Regards,</div><div>Tiago Sá</div><div><br><div><br></div><div><br><div class="gmail_quote">On Thu, Nov 17, 2011 at 9:42 PM, Youness Alaoui <span dir="ltr">&lt;<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 11/16/2011 08:30 PM, Tiago Sá wrote:<br>
&gt; Hi again Youness,<br>
&gt; thanks a lot for your help.<br>
&gt; I believe I solved the problems you pointed before.<br>
&gt; I am using a dumb method to exchange candidates. I write them to file and<br>
&gt; exchange them using a ftp server (I will improve it later).<br>
&gt;<br>
&gt; So, the way I run it is:<br>
&gt; (HostA) ./client l<br>
&gt; (HostB) ./client r<br>
&gt; //local candidates are gathered and written to file<br>
&gt; (HostA) put leftCands.bin on FTP and get rightCands.bin<br>
&gt; (HostB) put rightCands.bin on FTP and get leftCands.bin<br>
&gt; //read local credentials and write them on the remote host<br>
&gt;<br>
&gt; I am using a relay server, that should work as a last resort. But during the<br>
&gt; local candidate gathering, sometimes it gets a relayed candidate, but most of<br>
&gt; the times it doesn&#39;t. Can it be related with timeouts?<br>
</div>It&#39;s possible the timeouts are affecting it, but I doubt it, usually the RTT<br>
would be 200ms, but if you don&#39;t get a response from the relay or the stun<br>
server, it will retry 4 times until it times out after about 3 seconds.<br>
It&#39;s possible though that the server has a limit on the number of allocations<br>
you can create (probably 5) and if you are testing your app and it creates 2<br>
allocations each time (one for each side), then it&#39;s possible the server starts<br>
rejecting your allocation requests (each time you want to use TURN, it will ask<br>
the server to allocate a port for you for that specific connection, so you have<br>
the same settings but one port for each stream/component).<br>
If that&#39;s the case, maybe that&#39;s why it sometimes works (when the allocation<br>
times out from the server). libnice should technically deallocate when the<br>
stream is destroyed, so maybe catch your Ctrl-C and do an unref on the agent<br>
before returning from the main.<br>
<div class="im"><br>
&gt;<br>
&gt; Either way, it can never get a pair a establish a connection. :(<br>
&gt; I don&#39;t have a clue why this happens..<br>
<br>
</div>A log + wireshark dump might be helpful in this case. You can enable logging with :<br>
export NICE_DEBUG=all<br>
<div class="im"><br>
<br>
&gt;<br>
&gt; Can you please have a look?<br>
</div>The code looks sane enough.. apart from the obvious method of exchanging<br>
candidates which isn&#39;t &quot;optimal&quot;. One thing I noticed though, you just fwrite<br>
the whole structure, but note that there are pointers in the structure that will<br>
be written as is to the file, and not their content. I&#39;m thinking of<br>
username+password (but those should be NULL if you use the RFC5245 compatibility<br>
mode) but mostly the turn structure (which is just for local candidates and<br>
wouldn&#39;t be used anyways for remote ones, but it&#39;s best to set it to NULL to<br>
avoid possible crashes).<br>
<div class="im"><br>
&gt;<br>
&gt; Cheers,<br>
&gt; Tiago<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Nov 4, 2011 at 2:03 PM, Youness Alaoui &lt;<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a><br>
</div><div><div class="h5">&gt; &lt;mailto:<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi again Tiago,<br>
&gt;<br>
&gt;     For the remote candidates, you will need a third party server to exchange that<br>
&gt;     information, usually the candidates would be sent over SIP or XMPP for example.<br>
&gt;     ICE cannot work if you don&#39;t have a third party server with which you can<br>
&gt;     reliably exchange candidates. For testing purposes you could have it print the<br>
&gt;     candidates to stdout, and you could copy/paste that into stdin of the other<br>
&gt;     instance and have it parse the input.. or you could hardcode a port to connect<br>
&gt;     to and do the candidate exchange.. there&#39;s no easy way of doing that though.<br>
&gt;     You cannot hardcode the candidates because the port used will be random<br>
&gt;     everytime, also, you will need to exchange the randomly generated<br>
&gt;     username/password (nice_agent_get_local_credentials +<br>
&gt;     nice_agent_set_remote_credentials) to make the connectivity checks work.<br>
&gt;<br>
&gt;     As for your example, here are a few comments :<br>
&gt;     1 - you call the nice_agent_set_relay_info with stream_id being uninitialized,<br>
&gt;     you must call it *after* you do the nice_agent_add_stream...<br>
&gt;     2 - you don&#39;t need those GValues, you can just do<br>
&gt;      g_object_set (G_OBJECT(agent),<br>
&gt;                    &quot;stun-server&quot;, &quot;66.228.45.110&quot;,<br>
&gt;                    &quot;stun-server-port&quot;, 3478,<br>
&gt;                     NULL);<br>
&gt;     3 - You shouldn&#39;t set the remote credentials as the same as the local ones<br>
&gt;     4 - In your print_candidate_info, you may also want to print the port used.<br>
&gt;<br>
&gt;     I hope this helps, let me know if you have further questions.<br>
&gt;<br>
&gt;     Youness.<br>
&gt;<br>
&gt;<br>
&gt;     On 11/03/2011 12:57 PM, Tiago Sá wrote:<br>
&gt;     &gt; Hi Youness,<br>
&gt;     &gt;<br>
&gt;     &gt; I have been trying to create a simple application based on the first link you<br>
&gt;     &gt; pointed before.<br>
&gt;     &gt; Thanks for the tips you gave me. I have a couple of questions though, if<br>
&gt;     you can<br>
&gt;     &gt; help me.<br>
&gt;     &gt;<br>
&gt;     &gt; I need to find a way to get the remote candidates passed from a peer to<br>
&gt;     another.<br>
&gt;     &gt; Can you point an easy way to do that?<br>
&gt;     &gt; Could I hardcode the remote candidates list, for testing purposes?<br>
&gt;     &gt;<br>
&gt;     &gt; Right now, I only get two local candidates (HOST and SERVER_REFLEXIVE).<br>
&gt;     &gt; I am trying to use the numb TURN server, shouldn&#39;t I get a RELAYED<br>
&gt;     candidate too?<br>
&gt;     &gt;<br>
&gt;     &gt; I am attaching the code. Can you please have a look at the code and check<br>
&gt;     where<br>
&gt;     &gt; the error could be?<br>
&gt;     &gt;<br>
&gt;     &gt; Thanks for helping!<br>
&gt;     &gt;<br>
&gt;     &gt; Regards,<br>
&gt;     &gt; Tiago Sá<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; On Wed, Oct 19, 2011 at 10:53 PM, Youness Alaoui<br>
&gt;     &lt;<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a> &lt;mailto:<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>&gt;<br>
</div></div>&gt;     &gt; &lt;mailto:<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a><br>
<div><div class="h5">&gt;     &lt;mailto:<a href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>&gt;&gt;&gt; wrote:<br>
&gt;     &gt;<br>
&gt;     &gt;     Hi,<br>
&gt;     &gt;<br>
&gt;     &gt;     Welcome to the world of libnice :)<br>
&gt;     &gt;     Yes, doing NAT traversal is far from being easy, the only solution is<br>
&gt;     pretty<br>
&gt;     &gt;     much to use the ICE specification and that&#39;s not easy to implement, so<br>
&gt;     that&#39;s<br>
&gt;     &gt;     why you&#39;d need to use libnice.<br>
&gt;     &gt;<br>
&gt;     &gt;     For an example, you can have a look at the unit tests, like<br>
&gt;     &gt;     tests/test-fullmode.c for example, although that does a lot of stuff.<br>
&gt;     You can<br>
&gt;     &gt;     see a quick example  in the documentation for NiceAgent :<br>
&gt;     &gt;     <a href="http://nice.freedesktop.org/libnice/NiceAgent.html" target="_blank">http://nice.freedesktop.org/libnice/NiceAgent.html</a><br>
&gt;     &gt;<br>
&gt;     &gt;     For smaller examples, you can look at the libnice mailing list<br>
&gt;     archives, some<br>
&gt;     &gt;     people posted their example code where they were having problems. For<br>
&gt;     example, a<br>
&gt;     &gt;     very simple example can be seen here :<br>
&gt;     &gt;     <a href="http://lists.freedesktop.org/archives/nice/2011-January/000404.html" target="_blank">http://lists.freedesktop.org/archives/nice/2011-January/000404.html</a><br>
&gt;     &gt;     But make sure to click on the &quot;Next message&quot; to read the whole thread<br>
&gt;     because<br>
&gt;     &gt;     that example had a bug that I explained how to fix in the following<br>
&gt;     emails.<br>
&gt;     &gt;     Same for this thread :<br>
&gt;     &gt;     <a href="http://lists.freedesktop.org/archives/nice/2011-October/000434.html" target="_blank">http://lists.freedesktop.org/archives/nice/2011-October/000434.html</a><br>
&gt;     &gt;<br>
&gt;     &gt;     I hope that helps,<br>
&gt;     &gt;     Youness.<br>
&gt;     &gt;<br>
&gt;     &gt;     On 10/19/2011 09:58 AM, Tiago Sá wrote:<br>
&gt;     &gt;     &gt; Hi all,<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt; my name is Tiago Sá, I am a junior researcher from Portugal and this<br>
&gt;     is my<br>
&gt;     &gt;     first<br>
&gt;     &gt;     &gt; mail to this list.<br>
&gt;     &gt;     &gt; I have a NAT traversal problem to solve and I have been looking for<br>
&gt;     a solution<br>
&gt;     &gt;     &gt; during the last weeks, which, as I found out, is not so trivial as I<br>
&gt;     &gt;     thought before.<br>
&gt;     &gt;     &gt; As stated on the libnice homepage, libnice seems to be what I am<br>
&gt;     looking for:<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt;     &quot;ICE is useful for applications that want to establish peer-to-peer<br>
&gt;     &gt;     UDP data<br>
&gt;     &gt;     &gt;     streams. It automates the process of traversing NATs and<br>
&gt;     provides security<br>
&gt;     &gt;     &gt;     against some attacks. It also allows applications to create reliable<br>
&gt;     &gt;     streams<br>
&gt;     &gt;     &gt;     using a TCP over UDP layer.&quot;<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt; I have been looking for the provided documentation and I am feeling kind<br>
&gt;     &gt;     of lost.<br>
&gt;     &gt;     &gt; Is there any example application or tutorial to get started?<br>
&gt;     &gt;     &gt; Could you please share a basic application of this kind or point me a<br>
&gt;     &gt;     direction?<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt; Thanks in advance for your help.<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt; Regards,<br>
&gt;     &gt;     &gt; Tiago Sá<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt; --<br>
&gt;     &gt;     &gt; Tiago Sá<br>
&gt;     &gt;     &gt; Universidade do Minho, Braga - Portugal<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt;  <a href="http://about.me/tiagosa/" target="_blank">http://about.me/tiagosa/</a><br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt; _______________________________________________<br>
&gt;     &gt;     &gt; Nice mailing list<br>
&gt;     &gt;     &gt; <a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a> &lt;mailto:<a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a>&gt;<br>
</div></div>&gt;     &lt;mailto:<a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a> &lt;mailto:<a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a>&gt;&gt;<br>
<div class="im">&gt;     &gt;     &gt; <a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;     _______________________________________________<br>
&gt;     &gt;     Nice mailing list<br>
&gt;     &gt;     <a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a> &lt;mailto:<a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a>&gt;<br>
</div>&gt;     &lt;mailto:<a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a> &lt;mailto:<a href="mailto:Nice@lists.freedesktop.org">Nice@lists.freedesktop.org</a>&gt;&gt;<br>
<div class="im">&gt;     &gt;     <a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; --<br>
&gt;     &gt; Tiago Sá<br>
&gt;     &gt; Universidade do Minho, Braga - Portugal<br>
</div>&gt;     &gt;  <a href="http://www.tiagosa.com" target="_blank">www.tiagosa.com</a> &lt;<a href="http://www.tiagosa.com" target="_blank">http://www.tiagosa.com</a>&gt; &lt;<a href="http://www.tiagosa.com" target="_blank">http://www.tiagosa.com</a>&gt;<br>


<div class="im">&gt;     &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Tiago Sá<br>
&gt; Universidade do Minho, Braga - Portugal<br>
</div>&gt;  <a href="http://www.tiagosa.com" target="_blank">www.tiagosa.com</a> &lt;<a href="http://www.tiagosa.com" target="_blank">http://www.tiagosa.com</a>&gt;<br>
&gt;<br>
<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Tiago Sá<br>Universidade do Minho, Braga - Portugal<div><img src="http://wac.2659.edgecastcdn.net/802659/production80/images/icons/favicon.ico"> <a href="http://www.tiagosa.com" target="_blank">www.tiagosa.com</a><br>

</div><br>
</div></div>