Handshake Timed Out on IOS Device with TLS

189 views
Skip to first unread message

Mehmet Faruk

unread,
Sep 17, 2020, 10:29:43 AM9/17/20
to rabbitmq-users
Hello,
I'm getting errors on this code. What is the problem. I can connect with 5672 but cant with 5671, the code and error I'm getting will be written in down. I might made somethings different to put all the code in one place but wanna know what is the wrong Im doing in here :) I asked question in slack thanks for answering but I think this time I need to send you the code, so I'm mailing it now. If you need more info, please tell me.

~~~~the code~~~~

//

//  ViewController.swift

//  Mytechnology App

//

//  Created by MFG on 7.09.2020.

//  Copyright © 2020 MFG. All rights reserved.

//

import UIKit

import RMQClient

import Foundation

//import XCTest


class ViewController: UIViewController {

    @IBOutlet weak var editText: UITextField!

    @IBOutlet weak var textView: UILabel!

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view.

    }

    

    var text:String = ""

    

    //burada text degiskenimizi ayarliyoruz.

    func send(message:String) { //bu fonksiyonun amaci mesaj gonderimi yapmak

        

        print("Attempting to connect to local RabbitMQ broker")

        let delegate = RMQConnectionDelegateLogger()

        let tlsOptions = RMQTLSOptions(

            peerName: "192.xxx.x.xx",

            verifyPeer: true,

            pkcs12: fixtureClientCertificatePKCS12() as Data,

            pkcs12Password: CertificateFixtures.password

        )

        let conn = RMQConnection(uri: "amqp://test:te...@192.xxx.xx.xx:5671//",

                                   tlsOptions: tlsOptions,

                                   delegate: delegate)

        conn.start()

        //defer { conn.blockingClose() }

        let ch = conn.createChannel()

        let q = ch.queue("go")

        let body = message.data(using: String.Encoding.utf8)!

        q.publish(body)

        //mesaj gonderimi islemini yapacak burasi

        print("Sent \(message)")

    }

    

    //butona tiklandiginda asagisi calisacak

    @IBAction func buttonClick(_ sender: UIButton) {

        text = editText.text!

        self.send(message: text) //burada ekrandan (kullanicidan) veri alinacak

        textView.text =  text //ekranda da yazdiralim dedim

    }

    

    //silmek istersek ekranda goruneni bu fonksiyon calisacak

    @IBAction func clear(_ sender: UIButton) {

        textView.text =  "Cleared"

        editText.text = ""

    }

    

    //bu lazim olacak tls icin..

    fileprivate func fixtureClientCertificatePKCS12() -> Data {

        do {

            return try CertificateFixtures.guestBunniesP12()

        } catch {

            fatalError("Failed to load the fixture client certificate")

        }

    }

    

}


//burasi ulasilmasi istenen dosyalara gidiyor, sifrede var..

class CertificateFixtures {

    static let password = "bunnies"

    static func guestBunniesP12() throws -> Data {

        let bundle = Bundle.init(for: self)

        //print("aaa")

        guard let certURL = bundle.url(forResource: "client_key",

                                       withExtension: "p12", subdirectory: "ios_tls_mfg") else {

            let err = "Failed to load client_key.p12 from the bundle! Resourcee path: \(bundle.resourcePath!)"

            print("error mfg errrorrr")

            preconditionFailure(err)

     

        }

        return try Data(contentsOf: certURL)

    }

}

~~~~code finished~~~~

~~~~the error i am getting~~~~

Attempting to connect to local RabbitMQ broker

Sent mfg_deneme

2020-09-17 16:01:24.015097+0300 ios_mqtt[93340:2640719] Received connection: <RMQConnection: 0x600001d1cbd0> disconnectedWithError: Error Domain=kCFStreamErrorDomainSSL Code=-9807 "(null)" UserInfo={NSLocalizedRecoverySuggestion=Error code definition can be found in Apple's SecureTransport.h}

2020-09-17 16:01:38.975724+0300 ios_mqtt[93340:2640720] Received connection: <RMQConnection: 0x600001d1cbd0> failedToConnectWithError: Error Domain=com.rabbitmq.rabbitmq-objc-client Code=1 "Handshake timed out." UserInfo={NSLocalizedDescription=Handshake timed out.}

2020-09-17 16:01:38.975823+0300 ios_mqtt[93340:2641282] Will start recovery for connection: <RMQConnection: 0x600001d1cbd0>

2020-09-17 16:01:38.975848+0300 ios_mqtt[93340:2640719] Starting recovery for connection: <RMQConnection: 0x600001d1cbd0>

2020-09-17 16:01:39.346433+0300 ios_mqtt[93340:2640720] Received connection: <RMQConnection: 0x600001d1cbd0> disconnectedWithError: Error Domain=kCFStreamErrorDomainSSL Code=-9807 "(null)" UserInfo={NSLocalizedRecoverySuggestion=Error code definition can be found in Apple's SecureTransport.h}

~~~~the error i am getting is finished~~~~

Mehmet Faruk

unread,
Sep 21, 2020, 2:21:48 PM9/21/20
to rabbitm...@googlegroups.com
Problem solved. If anyone who try to solve this problem, thank you. If you need any help, please let me know.
Work hard :)

--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/ZMgHrBSvCss/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/7ff97f2b-7c43-4732-b332-da01fb6ff199n%40googlegroups.com.

santhosh R

unread,
Feb 7, 2024, 6:39:48 AM2/7/24
to rabbitmq-users
Hi Bro How do You fixed this one. Can you let me know 
Reply all
Reply to author
Forward
0 new messages