lucazanrosso / OPCUAClient

A basic android app that implements an OPC UA client.
11 stars 5 forks source link

I couldn''t connect my opc ua server via user name and password #1

Open phucpham98 opened 4 years ago

phucpham98 commented 4 years ago

Hi guy, I couldn''t connect my opc ua server via user name and password. Can you help me?. Thanks

lucazanrosso commented 4 years ago

Hello! This is a job I did 2 years ago so I hope I can answer you. I'm asking you some things to better understand the problem. Did you find the endpoints yet? Did you follow my thesis or did you create your own server? (you can find the pdf thesis in the master)

phucpham98 commented 4 years ago

I have a my own opc ua server. It's security is Sign&Encrypt and Basic256SHA256. I connect it with username and password. But when i click button connect, it show textview: "connecting failed". No certificate file was created on my server in other to I accept.

Vào Th 6, 31 thg 7, 2020 lúc 02:44 lucazanrosso notifications@github.com đã viết:

Hello! This is a job I did 2 years ago so I hope I can answer you. I'm asking you some things to better understand the problem. Did you find the endpoints yet? Did you follow my thesis or did you create your own server? (you can find the pdf thesis in the master)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-666641472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJW3QOVM3XXICMXXEX3R6HEQXANCNFSM4PNT2HBQ .

lucazanrosso commented 4 years ago

Excuse me for asking again, but I need it to figure out what the problem is. Were you able to find the endpoints? I'm asking because maybe the problem is before the connection.

phucpham98 commented 4 years ago

How to know I found the endpoints? I modified the code with my endpoint, my security and my value on server to read. After that, I run project, but when I click connect button, it show text view "connection fail". I find out certificate file on my sẻver to accept, but it not created.

Vào CN, 2 thg 8, 2020 lúc 02:22 lucazanrosso notifications@github.com đã viết:

Excuse me for asking again, but I need it to figure out what the problem is. Were you able to find the endpoints? I'm asking because maybe the problem is before the connection.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-667576098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJWFXC2LATQF3KE2TALR6RTQPANCNFSM4PNT2HBQ .

lucazanrosso commented 4 years ago

In DISCOVER ENDPOINT section in MainActivity I wrote these lines at the end of the section:

System.out.println("Security Level " + endpoint.getSecurityPolicyUri());
System.out.println("Security Mode " + endpoint.getSecurityMode());

On android studio you can see what is written so you can see if you can find the endpoints and also the level and mode security.

phucpham98 commented 4 years ago

I think my problem is variable my client initializer is redundant and i couldn't fix it [image: image.png]

Vào CN, 2 thg 8, 2020 vào lúc 16:11 lucazanrosso notifications@github.com đã viết:

In DISCOVER ENDPOINT section i wrote these lines at the end of the section:

System.out.println("Security Level " + endpoint.getSecurityPolicyUri()); System.out.println("Security Mode " + endpoint.getSecurityMode());

On android studio you can see what is written so you can see if you can find the endpoints and also the level and mode security.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-667648932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJSXTHHBP22DZD2R4L3R6UUSHANCNFSM4PNT2HBQ .

phucpham98 commented 4 years ago

Hi guy, hope you help me, please. Many thanks

Vào CN, 2 thg 8, 2020 vào lúc 16:11 lucazanrosso notifications@github.com đã viết:

In DISCOVER ENDPOINT section i wrote these lines at the end of the section:

System.out.println("Security Level " + endpoint.getSecurityPolicyUri()); System.out.println("Security Mode " + endpoint.getSecurityMode());

On android studio you can see what is written so you can see if you can find the endpoints and also the level and mode security.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-667648932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJSXTHHBP22DZD2R4L3R6UUSHANCNFSM4PNT2HBQ .

lucazanrosso commented 4 years ago

I'm really sorry, but I can't download the project and check it out at the moment. Were you able to figure anything out in the meantime?

phucpham98 commented 4 years ago

Vào CN, 16 thg 8, 2020 lúc 18:36 lucazanrosso notifications@github.com đã viết:

I'm really sorry, but I can't download the project and check it out at the moment. Were you able to figure anything out in the meantime?

Can you check it when you free, many thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-674515572, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJX52ILA643PSPLDAADSA7ACJANCNFSM4PNT2HBQ .

phucpham98 commented 4 years ago

In DISCOVER ENDPOINT section in MainActivity I wrote these lines at the end of the section:

System.out.println("Security Level " + endpoint.getSecurityPolicyUri());
System.out.println("Security Mode " + endpoint.getSecurityMode());

On android studio you can see what is written so you can see if you can find the endpoints and also the level and mode security.

it dont display Security Level and Security Mode in android studio

lucazanrosso commented 4 years ago

If you don't want to use System.out.println you can use:

I recommended Logs in this case

phucpham98 commented 4 years ago

Hi guys, I see and this is my logcat: 2020-09-10 15:49:46.544 8739-8857/com.lucazanrosso.opcuaclient W/System.err: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 2020-09-10 15:49:46.544 8739-8857/com.lucazanrosso.opcuaclient W/System.err: SLF4J: Defaulting to no-operation (NOP) logger implementation 2020-09-10 15:49:46.544 8739-8857/com.lucazanrosso.opcuaclient W/System.err: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 2020-09-10 15:49:46.804 8739-8857/com.lucazanrosso.opcuaclient I/System.out: Generating new Certificate for Client using CN: UA Sample Client 2020-09-10 15:49:48.235 8739-8857/com.lucazanrosso.opcuaclient I/System.out: Security Level http://opcfoundation.org/UA/SecurityPolicy#None 2020-09-10 15:49:48.235 8739-8857/com.lucazanrosso.opcuaclient I/System.out: Security Mode None

I think error is: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

Vào Th 5, 10 thg 9, 2020 vào lúc 15:49 lucazanrosso < notifications@github.com> đã viết:

If you don't wanto to use System.out.println you can use:

-

Logs https://developer.android.com/studio/debug/am-logcat

Toast https://developer.android.com/guide/topics/ui/notifiers/toasts#java

I recommended Logs in this case

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-690089951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJXA5HRDSEYF2MIV4CTSFCHH3ANCNFSM4PNT2HBQ .

lucazanrosso commented 4 years ago

Ok now with the logcat you can better understand the problem. Anyway, yes, the first problem to solve is the SLF4J libraries. I don't know if you have already read it but in my thesis I write in detail all the steps to do. https://github.com/lucazanrosso/OPCUAClient/blob/master/OPCUAClient%20guide.pdf

lucazanrosso commented 4 years ago

Anyway as I told you I'm sorry I can't help you directly with Android Studio but right now I'm abroad for many months for study and I don't have the PC with Android Studio installed anymore.

phucpham98 commented 4 years ago

I have read your thesis carefully. I use your project on your github and just modify info of my server

Vào Th 5, 10 thg 9, 2020 lúc 16:04 lucazanrosso notifications@github.com đã viết:

Ok now with the logcat you can better understand the problem. Anyway, yes, the first problem to solve is the SLF4J libraries. I don't know if you have already read it but in my thesis I write in detail all the steps to do. https://github.com/lucazanrosso/OPCUAClient/blob/master/OPCUAClient%20guide.pdf

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-690098101, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJRQDKO5AIWMYGVQU4DSFCJA3ANCNFSM4PNT2HBQ .

phucpham98 commented 4 years ago

Thank you for your support

Vào Th 5, 10 thg 9, 2020 lúc 16:06 lucazanrosso notifications@github.com đã viết:

Anyway as I told you I'm sorry I can't help you directly with Android Studio but right now I'm abroad for many months for study and I don't have the PC with Android Studio installed anymore.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-690099429, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJQDH7UHYAWODZAVMBLSFCJKNANCNFSM4PNT2HBQ .

phucpham98 commented 4 years ago

I solved th SLF4J lib problem. But i can not connect with server

Vào Th 5, 10 thg 9, 2020 vào lúc 16:06 lucazanrosso < notifications@github.com> đã viết:

Anyway as I told you I'm sorry I can't help you directly with Android Studio but right now I'm abroad for many months for study and I don't have the PC with Android Studio installed anymore.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-690099429, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJQDH7UHYAWODZAVMBLSFCJKNANCNFSM4PNT2HBQ .

lucazanrosso commented 4 years ago

What's the Logcat now?

phucpham98 commented 4 years ago

Here is my logcat

2020-09-12 10:16:21.677 31922-32197/com.lucazanrosso.opcuaclient I/System.out: Generating new Certificate for Client using CN: UA Sample Client 2020-09-12 10:16:23.277 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] INFO org.opcfoundation.ua.utils.CryptoUtil - Using SecurityProvider SC 2020-09-12 10:16:23.702 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /103.151.124.XXX:4852 Connecting 2020-09-12 10:16:23.841 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /103.151.124.XXX:4852 Connected 2020-09-12 10:16:24.025 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] INFO org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp - -1662192XXX Closed 2020-09-12 10:16:24.037 31922-32205/com.lucazanrosso.opcuaclient W/System.err: [TcpConnection/Read] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /103.151.124.XXX:4852 Closed (expected) 2020-09-12 10:16:24.038 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /103.151.124.XXX:4852 Closed 2020-09-12 10:16:24.040 31922-32197/com.lucazanrosso.opcuaclient I/System.out: Security Level http://opcfoundation.org/UA/SecurityPolicy#None 2020-09-12 10:16:24.040 31922-32197/com.lucazanrosso.opcuaclient I/System.out: Security Mode None 2020-09-12 10:16:24.139 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - WIN-7XWFHPQOXXX:4852 Connecting 2020-09-12 10:16:24.140 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - WIN-7XWFHPQOXXX:4852 Connect failed 2020-09-12 10:16:24.141 31922-32197/com.lucazanrosso.opcuaclient W/System.err: java.net.UnknownHostException: WIN-7XWFHPQOXXX 2020-09-12 10:16:24.141 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:208) 2020-09-12 10:16:24.141 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436) 2020-09-12 10:16:24.141 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.net.Socket.connect(Socket.java:621) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.transport.tcp.io.TcpConnection.open(TcpConnection.java:431) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.open(SecureChannelTcp.java:566) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSecureChannel(Client.java:644) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSecureChannel(Client.java:558) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSessionChannel(Client.java:422) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSessionChannel(Client.java:402) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at com.lucazanrosso.opcuaclient.MainActivity$ConnectionAsyncTask.doInBackground(MainActivity.java:122) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at com.lucazanrosso.opcuaclient.MainActivity$ConnectionAsyncTask.doInBackground(MainActivity.java:54) 2020-09-12 10:16:24.142 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at android.os.AsyncTask$3.call(AsyncTask.java:394) 2020-09-12 10:16:24.143 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266) 2020-09-12 10:16:24.143 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 2020-09-12 10:16:24.143 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 2020-09-12 10:16:24.143 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 2020-09-12 10:16:24.143 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.lang.Thread.run(Thread.java:923) 2020-09-12 10:16:24.176 31922-32197/com.lucazanrosso.opcuaclient W/System.err: [AsyncTask #1] WARN org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp - Connection failed: Bad_ConnectionRejected (code=0x80AC0000, description="2158755840, WIN-7XWFHPQOXXX") 2020-09-12 10:16:26.131 31922-32197/com.lucazanrosso.opcuaclient W/System.err: org.opcfoundation.ua.common.ServiceResultException: Bad_ConnectionRejected (code=0x80AC0000, description="2158755840, WIN-7XWFHPQOXXX") 2020-09-12 10:16:26.131 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.transport.tcp.io.TcpConnection.open(TcpConnection.java:438) 2020-09-12 10:16:26.131 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.open(SecureChannelTcp.java:566) 2020-09-12 10:16:26.131 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSecureChannel(Client.java:644) 2020-09-12 10:16:26.131 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSecureChannel(Client.java:558) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSessionChannel(Client.java:422) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.application.Client.createSessionChannel(Client.java:402) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at com.lucazanrosso.opcuaclient.MainActivity$ConnectionAsyncTask.doInBackground(MainActivity.java:122) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at com.lucazanrosso.opcuaclient.MainActivity$ConnectionAsyncTask.doInBackground(MainActivity.java:54) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at android.os.AsyncTask$3.call(AsyncTask.java:394) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) 2020-09-12 10:16:26.132 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 2020-09-12 10:16:26.133 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 2020-09-12 10:16:26.133 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.lang.Thread.run(Thread.java:923) 2020-09-12 10:16:26.133 31922-32197/com.lucazanrosso.opcuaclient W/System.err: Caused by: java.net.UnknownHostException: WIN-7XWFHPQOXXX 2020-09-12 10:16:26.133 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:208) 2020-09-12 10:16:26.135 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436) 2020-09-12 10:16:26.135 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at java.net.Socket.connect(Socket.java:621) 2020-09-12 10:16:26.136 31922-32197/com.lucazanrosso.opcuaclient W/System.err: at org.opcfoundation.ua.transport.tcp.io.TcpConnection.open(TcpConnection.java:431) 2020-09-12 10:16:26.136 31922-32197/com.lucazanrosso.opcuaclient W/System.err: ... 13 more

Vào Th 6, 11 thg 9, 2020 vào lúc 17:14 lucazanrosso < notifications@github.com> đã viết:

What's the Logcat now?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-691009509, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJSMXNPUDOJ3BFWPKNDSFHZ7PANCNFSM4PNT2HBQ .

phucpham98 commented 4 years ago

Can you suggest any solution to me?

Vào Th 6, 11 thg 9, 2020 vào lúc 17:14 lucazanrosso < notifications@github.com> đã viết:

What's the Logcat now?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucazanrosso/OPCUAClient/issues/1#issuecomment-691009509, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP7OWJSMXNPUDOJ3BFWPKNDSFHZ7PANCNFSM4PNT2HBQ .

lucazanrosso commented 4 years ago

Excuse me. I tried to read the Log but it is really long and difficult to understand. By chance can you find the source of the problem more specifically?