[zeromq-dev] assertion failed on zsocket_connect with ZMQ_REQ
Bachmair Florian - flexSolution GmbH
florian.bachmair at flexsolution.eu
Tue May 19 11:58:54 CEST 2015
but the assertion failed I get with that error
"Das Argument ist ungültig" (The Argument is invalid)
Am 19.05.2015 um 11:56 schrieb Bachmair Florian - flexSolution GmbH:
> Thank you!
>
>
> I get "Die Ressource ist zur Zeit nicht verfügbar" (The ressource is
> temporarily not available)
>
> what does that mean? What do I wrong?
>
> Am 19.05.2015 um 11:34 schrieb Pieter Hintjens:
>> Use 'puts ()' to print a string to the console.
>>
>> On Tue, May 19, 2015 at 11:28 AM, Bachmair Florian - flexSolution GmbH
>> <florian.bachmair at flexsolution.eu> wrote:
>>> ok that was not (my only) problem.
>>> It is also during execution.
>>>
>>> How can I print the strerror?
>>>
>>> int rc = zsocket_connect(req, "%s", addr);
>>> zmq_strerror (zmq_errno ());
>>> assert(rc == 0);
>>>
>>> does not print anything for me
>>>
>>> Am 19.05.2015 um 11:23 schrieb Bachmair Florian - flexSolution GmbH:
>>>> like that?
>>>>
>>>> int rc = zsocket_connect(req, "%s", addr);
>>>> zmq_strerror (zmq_errno ());
>>>> assert(rc == 0);
>>>>
>>>> this does not work.
>>>>
>>>> But I think I found the problem.
>>>> I start both applications at the same time, so the socket may not yet be initialized by the oponent.
>>>>
>>>>
>>>>
>>>> Am 19.05.2015 um 10:22 schrieb Pieter Hintjens:
>>>>> The problem is that the endpoint is rejected by your operating system
>>>>> as "invalid" for some reason; possibly networking is switched off. You
>>>>> can print strerror (errno) or zmq_strerror (zmq_errno ()) to see the
>>>>> actual error message.
>>>>>
>>>>> On Tue, May 19, 2015 at 10:14 AM, Bachmair Florian - flexSolution GmbH
>>>>> <florian.bachmair at flexsolution.eu> wrote:
>>>>>> 'addr' is tcp://127.0.0.1:9998
>>>>>> so the problem may be that the other side of the socket has crashed?
>>>>>>
>>>>>> I see that I do not close the 'req' Socket, could this be a problem?
>>>>>>
>>>>>> Am 19.05.2015 um 09:59 schrieb Pieter Hintjens:
>>>>>>> zsocket_connect does not block. It returns -1 if the endpoint is
>>>>>>> invalid, which presumably it is. Could you tell us what the value of
>>>>>>> 'addr' is ?
>>>>>>>
>>>>>>> On Tue, May 19, 2015 at 9:40 AM, Bachmair Florian - flexSolution GmbH
>>>>>>> <florian.bachmair at flexsolution.eu> wrote:
>>>>>>>> hi!
>>>>>>>>
>>>>>>>> Sometimes I get an assertion failed in my code.
>>>>>>>> Why is this? shouldn't it block, till a connection is established?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> NIEXPORT jstring JNICALL Java_eu_flexsolution_core_JNI_1zeromq_request(
>>>>>>>> JNIEnv *env, jobject object, jstring address, jstring timestamp,
>>>>>>>> jstring format, jstring command, jstring message) {
>>>>>>>> const char* addr = (*env)->GetStringUTFChars(env, address, 0);
>>>>>>>> const char* ts = (*env)->GetStringUTFChars(env, timestamp, 0);
>>>>>>>> const char* f = (*env)->GetStringUTFChars(env, format, 0);
>>>>>>>> const char* cmd = (*env)->GetStringUTFChars(env, command, 0);
>>>>>>>> const char* msg = (*env)->GetStringUTFChars(env, message, 0);
>>>>>>>>
>>>>>>>> printf("REQ:%s:%s:%s:%s:%s\n", addr,cmd, msg, f, ts);
>>>>>>>> fflush(stdout);
>>>>>>>> void *req = zsocket_new(context, ZMQ_REQ);
>>>>>>>> int rc = zsocket_connect(req, "%s", addr);
>>>>>>>> assert(rc == 0);
>>>>>>>> s_sendmore(req, ts);
>>>>>>>> s_sendmore(req, f);
>>>>>>>> s_sendmore(req, cmd);
>>>>>>>> s_send(req, msg);
>>>>>>>>
>>>>>>>> char* reply = s_recv(req);
>>>>>>>> printf("reply: %s\n", reply);
>>>>>>>> fflush(stdout);
>>>>>>>>
>>>>>>>> (*env)->ReleaseStringUTFChars(env, timestamp, ts);
>>>>>>>> (*env)->ReleaseStringUTFChars(env, format, f);
>>>>>>>> (*env)->ReleaseStringUTFChars(env, message, msg);
>>>>>>>>
>>>>>>>> jstring ret = (*env)->NewStringUTF(env, reply);
>>>>>>>> return ret;
>>>>>>>> }
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> zeromq-dev mailing list
>>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> zeromq-dev mailing list
>>>>>>> zeromq-dev at lists.zeromq.org
>>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>>> _______________________________________________
>>>>>> zeromq-dev mailing list
>>>>>> zeromq-dev at lists.zeromq.org
>>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>>> _______________________________________________
>>>>> zeromq-dev mailing list
>>>>> zeromq-dev at lists.zeromq.org
>>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>> _______________________________________________
>>>> zeromq-dev mailing list
>>>> zeromq-dev at lists.zeromq.org
>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list