- Setup two servers (localhost/master and localhost/stable with both master code…).
- enable federation app
- add the URL of the other server in the federation settings of each server (yellow sign is shown in front of the url then)
On localhost/stable run `php cron.php`:
```
{"reqId":"M+IXMjX0eH8kSZCObKNo","remoteAddr":"","app":"cron","message":"Run job with ID 13","level":0,"time":"2016-01-26T17:34:00+00:00","method":"--","url":"--"}
{"reqId":"M+IXMjX0eH8kSZCObKNo","remoteAddr":"","app":"no app in context","message":"Exception: {\"Exception\":\"GuzzleHttp\\\\Exception\\\\ClientException\",\"Message\":\"Client error response [url] http:\\\/\\\/localhost\\\/master\\\/ocs\\\/v2.php\\\/apps\\\/federation\\\/api\\\/v1\\\/shared-secret?format=json&url=http%3A%2F%2Flocalhost%2Fstable&token=OicCzFpdJrhEKzmo [status code] 403 [reason phrase] Forbidden\",\"Code\":403,\"Trace\":\"#0 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/Subscriber\\\/HttpError.php(32): GuzzleHttp\\\\Exception\\\\RequestException::create(Object(GuzzleHttp\\\\Message\\\\Request), Object(GuzzleHttp\\\\Message\\\\Response))\\n#1 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/Event\\\/Emitter.php(109): GuzzleHttp\\\\Subscriber\\\\HttpError->onComplete(Object(GuzzleHttp\\\\Event\\\\CompleteEvent), 'complete')\\n#2 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/RequestFsm.php(91): GuzzleHttp\\\\Event\\\\Emitter->emit('complete', Object(GuzzleHttp\\\\Event\\\\CompleteEvent))\\n#3 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/RequestFsm.php(132): GuzzleHttp\\\\RequestFsm->__invoke(Object(GuzzleHttp\\\\Transaction))\\n#4 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/react\\\/promise\\\/src\\\/FulfilledPromise.php(25): GuzzleHttp\\\\RequestFsm->GuzzleHttp\\\\{closure}(Array)\\n#5 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/ringphp\\\/src\\\/Future\\\/CompletedFutureValue.php(55): React\\\\Promise\\\\FulfilledPromise->then(Object(Closure), NULL, NULL)\\n#6 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/Message\\\/FutureResponse.php(43): GuzzleHttp\\\\Ring\\\\Future\\\\CompletedFutureValue->then(Object(Closure), NULL, NULL)\\n#7 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/RequestFsm.php(134): GuzzleHttp\\\\Message\\\\FutureResponse::proxy(Object(GuzzleHttp\\\\Ring\\\\Future\\\\CompletedFutureArray), Object(Closure))\\n#8 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/Client.php(165): GuzzleHttp\\\\RequestFsm->__invoke(Object(GuzzleHttp\\\\Transaction))\\n#9 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/Client.php(125): GuzzleHttp\\\\Client->send(Object(GuzzleHttp\\\\Message\\\\Request))\\n#10 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/lib\\\/private\\\/http\\\/client\\\/client.php(129): GuzzleHttp\\\\Client->get('http:\\\/\\\/localhos...', Array)\\n#11 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/apps\\\/federation\\\/backgroundjob\\\/getsharedsecret.php(145): OC\\\\Http\\\\Client\\\\Client->get('http:\\\/\\\/localhos...', Array)\\n#12 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/lib\\\/private\\\/backgroundjob\\\/job.php(52): OCA\\\\Federation\\\\BackgroundJob\\\\GetSharedSecret->run(Array)\\n#13 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/lib\\\/private\\\/backgroundjob\\\/queuedjob.php(42): OC\\\\BackgroundJob\\\\Job->execute(Object(OC\\\\BackgroundJob\\\\JobList), Object(OC\\\\Log))\\n#14 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/apps\\\/federation\\\/backgroundjob\\\/getsharedsecret.php(126): OC\\\\BackgroundJob\\\\QueuedJob->execute(Object(OC\\\\BackgroundJob\\\\JobList), Object(OC\\\\Log))\\n#15 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/apps\\\/federation\\\/backgroundjob\\\/getsharedsecret.php(115): OCA\\\\Federation\\\\BackgroundJob\\\\GetSharedSecret->parentExecute(Object(OC\\\\BackgroundJob\\\\JobList), Object(OC\\\\Log))\\n#16 \\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/cron.php(136): OCA\\\\Federation\\\\BackgroundJob\\\\GetSharedSecret->execute(Object(OC\\\\BackgroundJob\\\\JobList), Object(OC\\\\Log))\\n#17 {main}\",\"File\":\"\\\/Users\\\/morrisjobke\\\/Projects\\\/owncloud\\\/stable\\\/3rdparty\\\/guzzlehttp\\\/guzzle\\\/src\\\/Exception\\\/RequestException.php\",\"Line\":89}","level":3,"time":"2016-01-26T17:34:00+00:00","method":"--","url":"--"}
```
and on the other server (localhost/master):
```
{"reqId":"T\/5fpv8VlLjKxv2EdwcK","remoteAddr":"::1","app":"no app in context","message":"remote server (http:\/\/localhost\/stable) didn't send a valid token (got GgE6TdzbTLoDrnU+) while getting shared secret","level":3,"time":"2016-01-26T17:34:00+00:00","method":"GET","url":"\/master\/ocs\/v2.php\/apps\/federation\/api\/v1\/shared-secret?format=json&url=http%3A%2F%2Flocalhost%2Fstable&token=GgE6TdzbTLoDrnU%2B"}
{"reqId":"i1261Dc6pNMVoNpXHW\/q","remoteAddr":"::1","app":"no app in context","message":"remote server (http:\/\/localhost\/stable) didn't send a valid token (got Jte5TpKbbugCQsfT) while getting shared secret","level":3,"time":"2016-01-26T17:34:00+00:00","method":"GET","url":"\/master\/ocs\/v2.php\/apps\/federation\/api\/v1\/shared-secret?format=json&url=http%3A%2F%2Flocalhost%2Fstable&token=Jte5TpKbbugCQsfT"}
{"reqId":"IiNcXOEb+xJ9AhYgjbMY","remoteAddr":"::1","app":"no app in context","message":"remote server (http:\/\/localhost\/stable) didn't send a valid token (got pT4ZeYuNqWKY7tu+) while getting shared secret","level":3,"time":"2016-01-26T17:34:00+00:00","method":"GET","url":"\/master\/ocs\/v2.php\/apps\/federation\/api\/v1\/shared-secret?format=json&url=http%3A%2F%2Flocalhost%2Fstable&token=pT4ZeYuNqWKY7tu%2B"}
{"reqId":"P\/l1JsjrSpmpCzx2PPxd","remoteAddr":"::1","app":"no app in context","message":"remote server (http:\/\/localhost\/stable) didn't send a valid token (got OicCzFpdJrhEKzmo) while getting shared secret","level":3,"time":"2016-01-26T17:34:00+00:00","method":"GET","url":"\/master\/ocs\/v2.php\/apps\/federation\/api\/v1\/shared-secret?format=json&url=http%3A%2F%2Flocalhost%2Fstable&token=OicCzFpdJrhEKzmo"}
```
Also the job is remove from the background jobs list and therefore the server will never get secret if something bad happened. Also I don't understand why the clientException isn't catched,because the code is inside a try catch and the catch clause also specifies the clientException.
cc @schiesbn
I also don't understand why https://github.com/owncloud/core/blob/682821c71ed2af297170294632931be1ac769f25/apps/federation/backgroundjob/requestsharedsecret.php#L111-L111 is done? Why not make it inverse? Remove the job and stop execution if the server isn't listed in the DB anymore (same applies for the getsharedsecret job).