sacOO7 / socketcluster-client-java

Native java and android client for socketcluster framework in node.js
http://socketcluster.io/
Apache License 2.0
94 stars 43 forks source link

Can't auth by api/secret keys (Java app/Android). Key/Secret Pair Failed #32

Closed ablack13 closed 4 years ago

ablack13 commented 6 years ago

Hello. Can't authorize by api keys from Coinigy API (My Account -> Coinigy API - >Generate new key ->v1)

Source in Kotlin (but was on Java too. Same result)

`import com.neovisionaries.ws.client.WebSocketException import com.neovisionaries.ws.client.WebSocketFrame import io.github.sac.BasicListener import io.github.sac.ReconnectStrategy import io.github.sac.Socket import org.json.JSONObject

class EntryPoint { companion object { @JvmStatic fun main(args: Array) { //entry point val entryPoint = EntryPoint() entryPoint.openSocket() } }

private val url = "wss://sc-02.coinigy.com/socketcluster/"
private val apiKey = "8a0ab8baf5cb81b78dc5505027876cce"
private val apiSecret = "bd5a3aead6a2fb10756f099a60823d15"

private val socket = Socket(url)

private fun openSocket() {
    with(socket) {
        setListener(object : BasicListener {
            override fun onAuthentication(socket: Socket?, status: Boolean?) {
                val jsonObject = JSONObject()
                jsonObject.put("apiKey", apiKey)
                jsonObject.put("apiSecret", apiSecret)
                socket?.emit("auth", jsonObject, { name, error, data -> System.out.println("name::$name error::$error data::$data") })
            }

            override fun onConnectError(socket: Socket?, exception: WebSocketException?) =
                    System.out.println("Got connect error $exception")

            override fun onSetAuthToken(token: String?, socket: Socket?) =
                    socket!!.setAuthToken(token)

            override fun onConnected(socket: Socket?, headers: MutableMap<String, MutableList<String>>?) =
                    System.out.println("onConnected to end-point")

            override fun onDisconnected(socket: Socket?, serverCloseFrame: WebSocketFrame?, clientCloseFrame: WebSocketFrame?, closedByServer: Boolean) =
                    System.out.println("Disconnected from end-point")
        })
        setReconnection(ReconnectStrategy().setDelay(3000).setMaxAttempts(30))
        connect()
    }
}

}`

Log output:

onConnected to end-point May 20, 2018 12:17:26 PM io.github.sac.Socket$1 onFrame INFO: Message :{"data":{"pingTimeout":20000,"id":"iDJKmOeysy60hZkGABuU","isAuthenticated":false},"rid":1} May 20, 2018 12:17:26 PM io.github.sac.Socket$1 onFrame INFO: Message :{"data":"Key/Secret Pair Failed","rid":2,"error":{"errorCode":403,"errorMsg":"Key/Secret Pair Failed"}} name::auth error::{"errorCode":403,"errorMsg":"Key/Secret Pair Failed"} data::Key/Secret Pair Failed

ablack13 commented 6 years ago

image

Sending data is correct, but always return

INFO: Message :{"data":"Key/Secret Pair Failed","rid":2,"error":{"errorCode":403,"errorMsg":"Key/Secret Pair Failed"}}

@sacOO7 please help. 2 days can't connect to Coinigy socket by socketcluster client

sacOO7 commented 6 years ago

Sure @andrue, I will look into it šŸ‘

On May 20, 2018 10:06 PM, "Andrew Black" notifications@github.com wrote:

[image: image] https://user-images.githubusercontent.com/5351890/40281035-ba739d98-5c64-11e8-80d7-83f87339a274.png

Sending data is correct, but always return

INFO: Message :{"data":"Key/Secret Pair Failed","rid":2,"error":{" errorCode":403,"errorMsg":"Key/Secret Pair Failed"}}

@sacOO7 https://github.com/sacOO7 please help. 2 days can't connect to Coinigy socket by socketcluster client

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/32#issuecomment-390494611, or mute the thread https://github.com/notifications/unsubscribe-auth/AP8vSXmFe_TxNP80gjlw18cECMH-C2J6ks5t0ZuagaJpZM4UGAw4 .

sacOO7 commented 6 years ago

HI @ablack13 , the issue is probably due to coinigy server problem. They have shut it down due to some load balancing issues. You will find more details here https://github.com/Coinigy/api/issues/34

sacOO7 commented 6 years ago

Hi @ablack13 , I think coinigy websocket api is live now. I will probably write down a code snippet to connect with coinigy server in 1-2 days. Till then, you can enable watch on the repo. šŸ‘

sacOO7 commented 6 years ago

Hi @ablack13 @aliiizzz I have created a gist to represent code that connects properly to coinigy server. You can find it here https://gist.github.com/sacOO7/a3fc817dfc5c85cf21ec96f09869fdfc

sacOO7 commented 6 years ago

Hi @ablack13 @aliiizzz , if you don't have any updates in this, I will close the issue .