Unable to open a connection using Lucid Ocean C# Library

+2 votes

Good Day,

 

I am trying to work on a Hello world web application using LucidOcean.Multichain assembly using C# in Microsoft Visual Studio 2017. I am just trying to make a connection from the server to the server.

Following is my sample code taken from Multichain Developers website

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

MultiChainConnection connection = new MultiChainConnection()

                {

                    Hostname = "xxx.xxx.xx.79",

                    Port = 7349,

                    Username = "multichainrpc",

                    Password = "F4oMLnguUvNYyT6ZUjKQY7r7auGCYzgB8NncZDdZS8QE",

                    ChainName = "ChainName",

                    BurnAddress = "1XXXXXXWzyXXXXXXg2XXXXXXcTXXXXXXXqFAPD",

                    RootNodeAddress = "1WNtXcjb8L9c96JnQbwsQKFPBxgnm1AJK5zd5F"

                };

 

               

                MultiChainClient _Client = new MultiChainClient(connection);               

                JsonRpcResponse<string> response= _Client.Wallet.GetNewAddress();

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

When I run the daemon command, resulting information gives me two ports to work with,

First port is 7349 given in the following lines

 

 

If I use 7349 as a port, code throws following exception

The underlying connection was closed: The connection was closed unexpectedly

 

 

Second port is 7348 taken from following lines

  • Listening for API requests on port 7348 (local only - see rpcallowip setting)

If use 7348 as a port, code throws following exception

Unable to connect to the remote server, No connection could be made because the target machine actively refused it 169.254.88.79:7348

 

Please advise what port I should use and what could be the problem prohibiting the connection?

asked Jul 12, 2021 by Tayyab Hussain

1 Answer

+2 votes
Hello Tayyab, have you whitelisted your ip address in multichain.conf file of your node, by setting the rpcallowip? as you are trying to connect to a public IP you need to whitelist your IP address or allow connections from everywhere by setting the rpcallowip=0.0.0.0/0 in multichain.conf file. You should use 7348 port for all rpc connections.

 

On a side note, you should not expose the public IP with credentials on any public domain except for testing purposes.
answered Jul 12, 2021 by DarkBlaze
edited Jul 12, 2021 by DarkBlaze
Many thanks for your reply and guideline man, it worked once I added the "rpcallowip" parameter :-)

Can you kindly advice me further for any available documentation of LucidOcean.Multichain library???. It will be much easier for work if I have some sort of documentation for this library.

Many Thanks :-)
Hi, I am glad that it worked :), sorry I don't have any experience with the lucid ocean library and wasn't able to find any documentation, the best way I could find was looking into the github repository https://github.com/JonathanCrossland/multichain and reading all the supported methods, the readme.md provides a basic idea of how they have structured the wrapper, as for the exact methods LucidOcean.multichain > API have the exact method signatures whatever they are using so I will suggest you have a look on it.

also the library is a wrapper around the json rpc api of multichain which you can find with detailed documentation on https://www.multichain.com/developers/json-rpc-api/ for further reference and if you know how to make api calls from c# code you can always use the rpc api directly, hope this helps..
Many thanks for detailed reply, I will definitely look into these links :-)

One more question, since multichain is supposed to be a private & strictly permission based blockchain. It is a good candidate to be used for an enterprise in peer to peer network or perhaps between enterprises using shared/connected networks.

However, do you think it is practical to be used on internet as well as it will be definitely complex to manage permissions and privacy over the internet ??

Please share your thoughts on this.
HI, Tayyab, sorry for the late reply, when you say to be used on the internet do you mean, keeping the blockchain open for public use?
I will say it depends upon the use case, I find blockchain one of the major technologies which can bring transparency in various domains if kept as a ledger where the public can verify various claims, however, regarding the privacy matter, it is a major design decision that what details can be shared as the details and other data can be kept on the blockchain in an encrypted format. For instance, in a food supplychain, the consumer can verify different details about the item he is buying/consuming, where the permissioning part becomes necessary to enable only authenticated players to add data to the chain. Unless this data is shared and accessible on the internet the masses won't be able to know more about the product.
...