calls to Zimbra Server doesn't works from Virtual Machine

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
G71
Posts: 23
Joined: Fri Aug 19, 2016 10:01 am

calls to Zimbra Server doesn't works from Virtual Machine

Post by G71 »

Dears,
I'm testing my client application that "speaks" with a remote Zimbra Server .

This client works fine from my pc but not on Virtual Machine that I need as pre-production environment

The "client" calls a "createAppointment" request via SOAP, after have obtained regular authtoken.

So, the problem on VM has been raised when the client calls the createAppointment request. Seems that the problem is on the validation of the token since the authtoken request works fine ever.

In brief, from my pc I can do "authtoken and createappointment" requests fine.
From Virtual Machine I can request with success only the authtoken request. In the next createAppointment request,it doesn't works. The Zimbra Server seems doesn't answer.

My Virtual Machine is a Virtual Box machine (linux but this SO doesn't seems to be important) and has its "network" setted as bridge (not NAT), I need of "bridge" configuration because the machine has to be accessible from other IPs
I tried to change in NAT configuration and it works fine. So, seems to be a networking VM configuration problem. Not Zimbra.

However, if someone of you has been incurred on a similar problem and wants share ideas... is welcome :-)
liverpoolfcfan
Elite member
Elite member
Posts: 1100
Joined: Sat Sep 13, 2014 12:47 am

Re: calls to Zimbra Server doesn't works from Virtual Machine

Post by liverpoolfcfan »

Which zimbra release is it?

Is the VM's IP Address whitelisted on zimbra?

Have you dumped the SOAP response to see what you are actually getting back? There may be an error or at least a clue in the text.

Is the AuthRequest actually generating a session? With zimbra 8.6 and later (and possibly earlier versions with the proxy enabled) you do not necessarily get a session on the AuthRequest. In a multi-server environment you can get back a success on the AuthRequest - but if your request did not get routed to the MTA that is home to your account you need to do a follow-up NoOpRequest or something similar in order to actually get a session context created.
G71
Posts: 23
Joined: Fri Aug 19, 2016 10:01 am

Re: calls to Zimbra Server doesn't works from Virtual Machine

Post by G71 »

liverpoolfcfan wrote:Which zimbra release is it?
Zimbra ver. is: 8.6.0_GA_1200
liverpoolfcfan wrote:Is the VM's IP Address whitelisted on zimbra?
Yes
liverpoolfcfan wrote:Have you dumped the SOAP response to see what you are actually getting back? There may be an error or at least a clue in the text.
There are not error on message since the same client (with identical credential, data and so on...) works fine from on my local pc but doesn't works on VM.
liverpoolfcfan wrote:Is the AuthRequest actually generating a session? With zimbra 8.6 and later (and possibly earlier versions with the proxy enabled) you do not necessarily get a session on the AuthRequest. In a multi-server environment you can get back a success on the AuthRequest - but if your request did not get routed to the MTA that is home to your account you need to do a follow-up NoOpRequest or something similar in order to actually get a session context created.
Please, can you clarify better?

How I said, the requests are two, the first one, for auth request and the second one for the create an appointment. My idea is that Zimbra checks, in some manner, the authrequest code sent as "value" on createAppointment request. Zimbra for some reason that I don't know, can't recognize from who has been sent. Other point, if I send a createAppointment req with a wrong autrequest id, correctly, I'll get a bad response.

Thank you for your time

G71
liverpoolfcfan
Elite member
Elite member
Posts: 1100
Joined: Sat Sep 13, 2014 12:47 am

Re: calls to Zimbra Server doesn't works from Virtual Machine

Post by liverpoolfcfan »

Just because it works from your local PC does not mean it will not get an error when running from a different machine. You should dump the contents of the response to make sure that you are not getting back a HTTP error message.

As regards the "session". When you do an AuthRequest you need to ask it to create a session context and to return that session identifier to you. If your request gets forwarded by the proxy to your home MTA for authentication then a session will be created and the id will be returned in the response (In PHP ... if (isset($contents['Body']['AuthResponse']['session'])). However, if your request got passed to a different non-home MTA, it can still validate you and return a positive response but, it does not create a session context and does not return a session id. In this case sending a "NoOpRequest" to the server with a header requesting a new session context will generate a session and will return the ID (in PHP ... $this->_sessionid = $contents['Header']['context']['session']['id'];)

If you can read PHP code you can see how it is handled it in the Z-Push Zimbra Backend project https://sourceforge.net/projects/zimbrabackend/ - Search for the AuthRequest and note the context header supplied for that call, then in processing the AuthResponse note the handling if 'session' was not found.
G71
Posts: 23
Joined: Fri Aug 19, 2016 10:01 am

Re: calls to Zimbra Server doesn't works from Virtual Machine

Post by G71 »

liverpoolfcfan wrote:Just because it works from your local PC does not mean it will not get an error when running from a different machine. You should dump the contents of the response to make sure that you are not getting back a HTTP error message.
I can't get the response content because I don't have it. The request goes timeout or better: the first one request (authrequest) works, the second request (createAppointment) goes timeout.
liverpoolfcfan wrote:As regards the "session". When you do an AuthRequest you need to ask it to create a session context and to return that session identifier to you. If your request gets forwarded by the proxy to your home MTA for authentication then a session will be created and the id will be returned in the response (In PHP ... if (isset($contents['Body']['AuthResponse']['session'])). However, if your request got passed to a different non-home MTA, it can still validate you and return a positive response but, it does not create a session context and does not return a session id. In this case sending a "NoOpRequest" to the server with a header requesting a new session context will generate a session and will return the ID (in PHP ... $this->_sessionid = $contents['Header']['context']['session']['id'];)

If you can read PHP code you can see how it is handled it in the Z-Push Zimbra Backend project https://sourceforge.net/projects/zimbrabackend/ - Search for the AuthRequest and note the context header supplied for that call, then in processing the AuthResponse note the handling if 'session' was not found.
When you are talking about "NoOpRequest", are you talking about a particular setting that have to be done on client side?

Thanks

G71
liverpoolfcfan
Elite member
Elite member
Posts: 1100
Joined: Sat Sep 13, 2014 12:47 am

Re: calls to Zimbra Server doesn't works from Virtual Machine

Post by liverpoolfcfan »

Are you accessing the zimbra server through the proxy - or are you trying to go to the MTA directly?

It would seem that you are not getting everything set up correctly for using the auth token on the subsequent call. Again, I would refer you to the PHP file I mentioned above if you can read it. It shows where to put the auth token in the SOAP context header. It is also required to set it as a cookie on the cURL request - not sure how you would do this on a direct SOAP function call.

// Set the session ID as a CURL cookie. This is required to traverse an nginx proxy and get subsequent
// requests passed to the correct Mail Store for the user account
curl_setopt($this->_curl, CURLOPT_COOKIE, 'ZM_AUTH_TOKEN='.$this->_authtoken);

This is the only way the session will be allowed to pass through the nginx proxy to get to the required MTA for processing.


NoOpRequest is just another soap command for zimbra. The webclient uses it to block waiting for changes to be notified. Search for the function NoOp in the API https://files.zimbra.com/docs/soap_api/ ... index.html
Post Reply