Jump to content


P4.NET - IsValidConnection returns "Unicode clients require a unicode enabled server"

.NET C# p4 login

  • Please log in to reply
10 replies to this topic

#1 mister_wilson

mister_wilson

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationMontreal, Quebec

Posted 28 October 2014 - 05:07 PM

Hi,

Whenever I run one of my tools to connect to perforce through the API, from time to time I get a P4Exception error message "Invalid login!" ... "Unicode clients require a unicode enabled server"

When debugging my tool, I get to the IsValidConnection function in P4Connection.cs and the call to the "RunUnParsed" function returns an error message "Unicode clients require a unicode enabled server"

Can anyone tell me what the problem can be and how to resolve it?

public bool IsValidConnection(bool checkLogin, bool checkClient)
{
    P4ExceptionLevels oldExLevel = this.ExceptionLevel;
    try
    {
    this.ExceptionLevel = P4ExceptionLevels.NoExceptiononerrors;
    P4RecordSet r = Run("info");

    if (r.HasErrors()) return false;
    if (r.Records.Length != 1) return false;

    if (checkClient)
    {
    if (!r.Records[0].Fields.ContainsKey("clientName")) return false;
    if (r.Records[0].Fields["clientName"] == "*unknown*") return false;
    }
    if (checkLogin)
    {
    P4UnParsedRecordSet ur = RunUnParsed("login", "-s"); //<- Problem comes from here
    if (ur.HasErrors()) return false;
    }
    }
    catch
    {
    // something went way wrong
    return false;
}
    finally
    {
    // set the ExceptionLevel back
    this.ExceptionLevel = oldExLevel;
    }

    return true;
}

I'm currently using P4V Client v2014.2 - 951414. My server version is P4D/LINUX26X86_64/2013.2/872110 with Unicode support DISABLED. I've tried many things such as having no P4CHARSET variable set, setting P4CHARSET=none and/or P4_port_CHARSET=none prior to launching my tool. I've even tried setting the Charset property to "none" from within my tool's code. (i.e.: m_P4.Charset = "none")

Please let me know if there is any other information I can provide.

Thanks,

-Jonathan Wilson

#2 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 28 October 2014 - 06:53 PM

Hi Jonathan,

Thank you for sending your P4V and server version details.  To better trouble-shoot this, can you please confirm the following:

1) Are you using using P4.NET (http://wiki.workshop...com/wiki/P4.net) or P4API.NET?

2) Does your 'p4 -ztag info' output indicate the server is unicode enabled? The p4 -ztag info output will show
... unicode enabled

if the server is unicode enabled.

3) What is the operating system language locale set to?

4) Do you have more than one Perforce server? (Verifying in case the tool is pointing to another server expecting different settings)

5) Have you checked 'p4 set' command output? Use this output to also verify the P4CHARSET value. Make sure the P4CHARSET value is null.

#3 mister_wilson

mister_wilson

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationMontreal, Quebec

Posted 28 October 2014 - 08:09 PM

Hi P4Shimada,

Thanks for the quick response. Below are the answers to your questions.

1) I am using P4.NET (my P4API.DLL is at v2.0.0.0 - Runtime v4.0.30319)
2) No, The p4 -ztag info does not return any line with "... unicode enabled"
3) My OS language locale is currently set to English (Canada)
4) Yes, i do have more than one perforce server. My tool is linked to the current perforce instance through "Manage Custom Tools" where I pass the $p for the current instance.

5) Here is the output from "p4 set"

P4CHARSET=none (set -s)
P4EDITOR=C:\Windows\SysWOW64\notepad.exe (set)
P4PORT=p4-codetest.myhost.org:1666 (set)
P4USER=mister_wilson (set)
P4_p4-codetest.myhost.org:1666_CHARSET=none (set)

I should also mentione that I tried using "p4 passwd" to have my user authenticated through password instead of ticket but that didn't seem to fix the problem.

Thanks,

-Jonathan

#4 mister_wilson

mister_wilson

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationMontreal, Quebec

Posted 29 October 2014 - 03:44 PM

I believe I have fixed the problem. Like you said the P4CHARSET needs to be "null" and NOT "none"
However when I was trying to unset the variable it wouldn't work.

i.e.:
p4 set P4CHARSET=  
set P4CHARSET=

Finally I deleted the variable from the registry. I had to check the following 2 locations:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Perforce\Environment
HKEY_CURRENT_USER\Software\Perforce\Environment

Cheers,

-JW

#5 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 29 October 2014 - 05:13 PM

Hi Jonathan,

Thanks for the update. Yes, definitely null or just delete the variable altogether since it is not used on a non-unicode server. Have a good week! :-)

#6 Dadeos

Dadeos

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 30 October 2014 - 09:29 AM

Hi Shimada,

I too am suffering from this issue, although I am using P4Perl.

When combining the 2014.1 version of the P4Perl wrapper (http://ftp.perforce....ools/p4perl.tgz) with the 2014.2 P4API library (http://ftp.perforce....2013_static.zip) the system appears to automatically create a “P4_perforce:1666_CHARSET” variable with a value of “none”, the presence of this variable causes a “Unicode clients require a unicode enabled server.” error to be reported for all subsequent operations. If I manually delete the “P4_perforce:1666_CHARSET” variable (i.e. by executing “p4 set P4_perforce:1666_CHARSET=” from the command line) then the error is not generated for the next operation but the variable is recreated and errors are produced for every subsequent operation once more. This behaviour does not occur when using the 2014.1 P4API library (http://ftp.perforce....2012_static.zip).

I am connecting to a P4Port of “perforce:1666” which does not have Unicode enabled.

This would appear to either be an issue introduced into the 2014.2 P4API library or perhaps an unfortunate interaction between the 2014.1 P4Perl wrapper and the 2014.2 P4API library, although there does not currently appear to be an updated 2014.2 P4Perl wrapper available via the FTP site.

Thanks

Peter

#7 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 30 October 2014 - 06:15 PM

Hi Peter,

Sorry you are also running into this issue. Thank you for giving your versions of the P4Perl and the API. I am looking into this right now with development.

#8 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 30 October 2014 - 08:46 PM

Hi Peter,

This may be related to a change in the C++ P4API that the derived APIs build on top of:

ftp://ftp.perforce.com/perforce/r14.2/doc/user/p4apinotes.txt

Major new functionality in 2014.2

#820182 (Bug #41143) *
    A new p4 enviroment file is in use and clients will now
    detect the unicode mode of a server automatically.
    New Api calls related to this functionality are
    SetEnviroFile(), IsUnicode(), and GetTrans().
    Automatic detection of unicode mode can be disabled by
    calling SetTrans() prior to calling Init().  A SetTrans(0)
    call before Init() should suppress auto unicode detection
    and give behavior compatible with earlier api versions.

#9 Dadeos

Dadeos

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 30 October 2014 - 10:43 PM

Hi Shimada,

Indeed, but it appears that the functionality is not behaving as intended. The documentation states:


Quote


For Perforce services operating in the default (non-Unicode mode), P4CHARSET must be left unset (or set to none) on user workstations. If P4CHARSET is set, but the service is not operating in internationalized mode, the service returns the following error message:

Unicode clients require a unicode enabled server.



yet I am receiving this error/warning despite the fact that the value of the "P4_perforce:1666_CHARSET" variable is set to "none".

My client has been configured, via the new auto detection functionality, with Unicode support disabled and it is connecting to a server with Unicode support disabled but I am receiving an error/warning that I should only receive if my client had been configured to have Unicode enabled.

Thanks

Peter

#10 kmrteledynelecroy

kmrteledynelecroy

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 08 September 2015 - 06:27 PM

The following patch will implement the suggested change in the perlclientapi.cc so that
SetTrans is called before Init as suggested by P4Shimanda

This works for me when I had the same problem between the 2014.1.842847 PERL API and the most recent server 2015R1

Thanks P4Shimanda for the clues how to fix this.

--- p4perl-2014.1.842847/lib/perlclientapi.cc 2014-03-18 12:06:25.000000000 -0400
+++ p4perl-2014.1.842847.patched/lib/perlclientapi.cc 2015-09-08 14:00:51.402029063 -0400
@@ -132,7 +132,8 @@
  PerlIO_stdoutf("[P4]: Connecting to Perforce\n");

  ResetFlags();
-
+/* KMR add call to SetTrans to turn off unicode */
+ client->SetTrans(0);
  client->Init(&e);
  if (e.Test())
  ui->HandleError(&e);

#11 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 16 September 2015 - 09:06 PM

 kmrteledynelecroy, on 08 September 2015 - 06:27 PM, said:

The following patch will implement the suggested change in the perlclientapi.cc so that
SetTrans is called before Init as suggested by P4Shimanda

This works for me when I had the same problem between the 2014.1.842847 PERL API and the most recent server 2015R1

Thanks P4Shimanda for the clues how to fix this.

You are welcome, Keith. Thanks for trying the suggested fix and letting us know your results. Have a good week!





Also tagged with one or more of these keywords: .NET, C#, p4 login

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users